Skip to content

Commit 3248b24

Browse files
committed
fixes undefined buildPsr7Response bug (#864)
1 parent d64ff69 commit 3248b24

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Google/Http/REST.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use GuzzleHttp\Exception\RequestException;
2121
use Psr\Http\Message\RequestInterface;
2222
use Psr\Http\Message\ResponseInterface;
23+
use Psr\Http\Message\Response;
2324

2425
/**
2526
* This class implements the RESTful transport of apiServiceRequest()'s
@@ -77,12 +78,17 @@ public static function doExecute(ClientInterface $client, RequestInterface $requ
7778
throw $e;
7879
}
7980

80-
$exceptionResponse = $e->getResponse();
81-
if ($exceptionResponse instanceof \GuzzleHttp\Message\ResponseInterface) {
82-
$exceptionResponse = $httpHandler->buildPsr7Response($e->getResponse());
81+
$response = $e->getResponse();
82+
// specific checking for Guzzle 5: convert to PSR7 response
83+
if ($response instanceof \GuzzleHttp\Message\ResponseInterface) {
84+
$response = new Response(
85+
$response->getStatusCode(),
86+
$response->getHeaders() ?: [],
87+
$response->getBody(),
88+
$response->getProtocolVersion(),
89+
$response->getReasonPhrase()
90+
);
8391
}
84-
85-
$response = $exceptionResponse;
8692
}
8793

8894
return self::decodeHttpResponse($response, $request, $expectedClass);

0 commit comments

Comments
 (0)