From 9adc0f3c9f0e8946d276fb07f87019e1a923c82d Mon Sep 17 00:00:00 2001 From: Michael Dowling Date: Mon, 30 Sep 2013 10:30:46 -0700 Subject: [PATCH] Adding a response body if one is not found --- src/Guzzle/Http/Adapter/Curl/RequestMediator.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Guzzle/Http/Adapter/Curl/RequestMediator.php b/src/Guzzle/Http/Adapter/Curl/RequestMediator.php index 5f453711..b25863ae 100644 --- a/src/Guzzle/Http/Adapter/Curl/RequestMediator.php +++ b/src/Guzzle/Http/Adapter/Curl/RequestMediator.php @@ -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); } /**