Closed RocketMan closed 1 year ago
Hey @RocketMan, the Message body only allows $body
to be a string
, a ReadableStreamInterface
or a StreamInterface
(new Request
class for reference). It may have worked before when it was corrected to a string, but that was ultimately the wrong type to begin with. As you already mentioned, the solution here is to cast it into an allowed type, and then it should work.
I hope this helps :+1:
I'll think this should answer your question, so I'll close this ticket.
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 calledPsr7\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 reachingReact\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.