1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 10:03:27 +01:00

Adding a response body if one is not found

This commit is contained in:
Michael Dowling 2013-09-30 10:30:46 -07:00
parent 08255fc915
commit 9adc0f3c9f

View File

@ -102,11 +102,17 @@ class RequestMediator
*/
public function writeResponseBody($curl, $write)
{
if ($response = $this->transaction->getResponse()) {
return $response->getBody()->write($write);
} else {
if (!($response = $this->transaction->getResponse())) {
return 0;
}
// Add a default body on the response if one was not found
if (!($body = $response->getBody())) {
$body = new Stream(fopen('php://temp', 'r+'));
$response->setBody($body);
}
return $body->write($write);
}
/**