Skip to content

Can't read buffered request bodies? #529

@Firehed

Description

@Firehed

Relating to #523 (and others) - following those changes, I'm now seeing larger requests being buffered. On its own that's fine, but when larger requests are buffered, I'm now observing that when I try to read the request body, I always get an empty string.

That's caused by receiving React\Http\Io\HttpBodyStream in ServerRequest->getBody(), which has an out-of-spec __toString() implementation. Given that class is marked a @internal, I'm assuming that my actual request handler is receiving that in error.

In the meantime, I can make the buffer size high enough to bypass the problem, but that's not a real solution.

My bridge does nothing special - basic URL-based routing, and the request handler is (effectively) doing json_decode((string)$request->getBody()) which according to the StreamInterface spec should work.

Can you help establish if this is a bug (either here or in react/http), configuration error, or if there's something that needs to be performed on all ServerRequestInterface/StreamInterfaces to establish if there's buffering occurring and ensure that everything is read before the request is handled? This behavior doesn't seem to be noted in the PHP-PM documentation anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions