Nyholm / psr7

A super lightweight PSR-7 implementation
MIT License
1.15k stars 75 forks source link

Response::__toString() #209

Closed vanodevium closed 1 year ago

vanodevium commented 1 year ago

Is there any chance to stringify response object to string like \GuzzleHttp\Psr7\Message::toString() can do this.

Example of stringified response:

HTTP/1.1 200 OK
Content-Length: 9
Content-Type: application/json
Connection: keep-alive

{"boo":1}

This functionality is really important for TCP connections.

I would be grateful for any help.

boesing commented 1 year ago

Maybe this can be of help: https://github.com/laminas/laminas-httphandlerrunner/tree/2.6.x/src/Emitter

It can handle any PSR-7 ResponseInterface and does exactly what you need.

nicolas-grekas commented 1 year ago

This lib provides only PSR-7 methods.