Skip to content

Commit 92f6753

Browse files
authored
Merge pull request php-vcr#163 from alnorth/headers-with-colons
Fix for parsing header values that include colons followed by spaces
2 parents f3d6a43 + 88dfbb5 commit 92f6753

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/VCR/Util/HttpUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function parseHeaders(array $headers)
1919

2020
// Collect matching headers into groups
2121
foreach ($headers as $line) {
22-
list ($key, $value) = explode(': ', $line);
22+
list ($key, $value) = explode(': ', $line, 2);
2323
if (!isset($headerGroups[$key])) {
2424
$headerGroups[$key] = array();
2525
}

tests/VCR/Util/HttpUtilTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,16 @@ public function testParseHeadersMultiple()
128128
$outputArray = HttpUtil::parseHeaders($inputArray);
129129
$this->assertEquals($excpetedHeaders, $outputArray);
130130
}
131+
132+
public function testParseHeadersIncludingColons()
133+
{
134+
$inputArray = array(
135+
'dropbox-api-result: {"name": "a_file.txt"}'
136+
);
137+
$excpetedHeaders = array(
138+
'dropbox-api-result' => '{"name": "a_file.txt"}'
139+
);
140+
$outputArray = HttpUtil::parseHeaders($inputArray);
141+
$this->assertEquals($excpetedHeaders, $outputArray);
142+
}
131143
}

0 commit comments

Comments
 (0)