jenssegers / php-proxy

A PHP proxy script with https and post support
https://jenssegers.com
933 stars 266 forks source link

Need example how to change response body #86

Closed rik43 closed 3 years ago

rik43 commented 3 years ago

only change body and save headers. i`m try, and this doesnt work.

$response->setBody(Stream::factory('foo'));

this need create new response and copy all headers ?

xuzhenjun130 commented 3 years ago
//get body
$content = (string)$response->getBody()
  //change response body 
  $body = Utils::streamFor(json_encode($content));
  $response = $response->withBody($body);