Skip to content
This repository was archived by the owner on Apr 1, 2023. It is now read-only.

Commit cdafd57

Browse files
committed
minor #136 use HeaderCollection::toArray to fix lowercased header names (jdohuutin)
This PR was squashed before being merged into the 1.0-dev branch (closes #136). Discussion ---------- use HeaderCollection::toArray to fix lowercased header names When creating a Response in Goutte client from a GuzzleResponse, headers names are lowercased. (location, content-type instead of Location, Content-type). (see https://github.com/guzzle/guzzle/blob/master/src/Guzzle/Http/Message/Header/HeaderCollection.php#L44) Rather than use `getAll` method of `HeaderCollection`, we better use [`toArray`](https://github.com/guzzle/guzzle/blob/master/src/Guzzle/Http/Message/Header/HeaderCollection.php#L99). Commits ------- cee172e use HeaderCollection::toArray to fix lowercased header names
2 parents cf17313 + cee172e commit cdafd57

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

Goutte/Client.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Guzzle\Http\Exception\CurlException;
1818
use Guzzle\Http\Exception\BadResponseException;
1919
use Guzzle\Http\Message\Response as GuzzleResponse;
20-
use Guzzle\Http\Message\Header as GuzzleHeader;
2120
use Guzzle\Http\ClientInterface as GuzzleClientInterface;
2221
use Guzzle\Http\Client as GuzzleClient;
2322
use Guzzle\Http\Message\EntityEnclosingRequestInterface;
@@ -181,14 +180,7 @@ protected function addPostFiles($request, array $files, $arrayName = '')
181180

182181
protected function createResponse(GuzzleResponse $response)
183182
{
184-
$headers = $response->getHeaders()->getAll();
185-
$headers = array_map(function ($header) {
186-
if ($header instanceof GuzzleHeader) {
187-
return $header->toArray();
188-
}
189-
190-
return $header;
191-
}, $headers);
183+
$headers = $response->getHeaders()->toArray();
192184

193185
return new Response($response->getBody(true), $response->getStatusCode(), $headers);
194186
}

0 commit comments

Comments
 (0)