diff --git a/lib/Cake/Network/Http/HttpSocketResponse.php b/lib/Cake/Network/Http/HttpSocketResponse.php index 99d875c31..ceaaf3074 100644 --- a/lib/Cake/Network/Http/HttpSocketResponse.php +++ b/lib/Cake/Network/Http/HttpSocketResponse.php @@ -268,18 +268,28 @@ class HttpSocketResponse implements ArrayAccess { return false; } - preg_match_all("/(.+):(.+)(?:(?_unescapeToken($field); + } $value = trim($value); - $value = preg_replace("/[\t ]\r\n/", "\r\n", $value); - - $field = $this->_unescapeToken($field); - - if (!isset($header[$field])) { + if (!isset($header[$field]) || $continuation) { $header[$field] = $value; } else { $header[$field] = array_merge((array)$header[$field], (array)$value); diff --git a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php index 502340094..2fde8eb5e 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php @@ -267,10 +267,19 @@ class HttpResponseTest extends CakeTestCase { ); $this->assertEquals($expected, $r); - $header = "Multi-Line: I am a \r\nmulti line\t\r\nfield value.\r\nSingle-Line: I am not\r\n"; + $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nLink: \r\nX-Total-Count: 19\r\n"; $r = $this->HttpResponse->parseHeader($header); $expected = array( - 'Multi-Line' => "I am a\r\nmulti line\r\nfield value.", + 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', + 'Link' => '', + 'X-Total-Count' => '19', + ); + $this->assertEquals($expected, $r); + + $header = "Multi-Line: I am a\r\n multi line \r\n\tfield value.\r\nSingle-Line: I am not\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'Multi-Line' => "I am a multi line field value.", 'Single-Line' => 'I am not' ); $this->assertEquals($expected, $r);