Skip to content

Commit

Permalink
Response::getHeaders() returns array [name => [headers]] instead of […
Browse files Browse the repository at this point in the history
…name => header] (BC break!)

tests: added test for Response::getHeaders()
  • Loading branch information
dg committed Oct 31, 2019
1 parent b83e074 commit 052190c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Http/IResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function getHeader(string $header): ?string;

/**
* Returns a associative array of headers to sent.
* @return string[][]
*/
function getHeaders(): array;

Expand Down
5 changes: 3 additions & 2 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,14 @@ public function getHeader(string $header): ?string

/**
* Returns a associative array of headers to sent.
* @return string[][]
*/
public function getHeaders(): array
{
$headers = [];
foreach (headers_list() as $header) {
$a = strpos($header, ':');
$headers[substr($header, 0, $a)] = (string) substr($header, $a + 2);
$pair = explode(': ', $header);
$headers[$pair[0]][] = $pair[1];
}
return $headers;
}
Expand Down

0 comments on commit 052190c

Please sign in to comment.