Skip to content

Response::getBody->getContents() returns empty string #34

@mhouriet

Description

@mhouriet

Hey,

In ResponseSigner.php the Response body stream in being consumed by signResponse() at line 60. Although explicit casting using __toString() will always rewind a stream before reading it, calling the getContents() method from StreamInterface will not. As a result, the middleware is breaking expected behavior, since Response::getBody()->getContents() will always return empty string after a POST.

I fixed it with a simple $response->getBody()->rewind() just after assigning $parts. I guess you can also use tell() and the seek() but I failed to find any real-life scenarios where it would make sense for a middleware to start reading the stream halfway through.

Do you want a pull request for this or is the fix trivial enough like this?

Cheers,

Matt

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