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:
parent
08255fc915
commit
9adc0f3c9f
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user