Skip to content

Regression: object with __toString no longer being accepted as request body in Browser post #498

@RocketMan

Description

@RocketMan

This may well be by design, so please feel free to close if so. I want to document it in case it is an unintentional regression.

I am proxying events from a WebSocket stream (via Ratchet) to HTTP POST (via react Browser).

In react/http 1.7.0, I could call the Browser method post, passing as the request body the message object from Ratchet, a \Ratchet\RFC6455\Messaging\Message. This class has a __toString method. It seems in 1.7.0, the Browser implementation ultimately called Psr7\stream_for, which coerced the object to a string via __toString.

In react/http 1.9.0, an InvalidArgumentException is raised with 'Invalid request body given'. In this case, Browser is now ultimately reaching React\Http\Message\Request, which requires an explicit string as the request body, as opposed to an object that can be converted to a string.

The solution is simple enough: I cast the Message object to string and everyone is happy.

Thanks for reading and for the excellent work behind ReactPHP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions