Skip to content

Commit 052190c

Browse files
committed
Response::getHeaders() returns array [name => [headers]] instead of [name => header] (BC break!)
tests: added test for Response::getHeaders()
1 parent b83e074 commit 052190c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Http/IResponse.php

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ function getHeader(string $header): ?string;
193193

194194
/**
195195
* Returns a associative array of headers to sent.
196+
* @return string[][]
196197
*/
197198
function getHeaders(): array;
198199

src/Http/Response.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,14 @@ public function getHeader(string $header): ?string
200200

201201
/**
202202
* Returns a associative array of headers to sent.
203+
* @return string[][]
203204
*/
204205
public function getHeaders(): array
205206
{
206207
$headers = [];
207208
foreach (headers_list() as $header) {
208-
$a = strpos($header, ':');
209-
$headers[substr($header, 0, $a)] = (string) substr($header, $a + 2);
209+
$pair = explode(': ', $header);
210+
$headers[$pair[0]][] = $pair[1];
210211
}
211212
return $headers;
212213
}

0 commit comments

Comments
 (0)