Skip to content
Permalink
Browse files

Don't split strings headers that lack a ':'.

Refs #9106
  • Loading branch information...
markstory committed Jul 13, 2016
1 parent 6bccfe9 commit 4e1b601ed8846439d11076895ed913c2bcd85393
Showing with 6 additions and 2 deletions.
  1. +1 −1 lib/Cake/Network/CakeResponse.php
  2. +5 −1 lib/Cake/Test/Case/Network/CakeResponseTest.php
@@ -577,7 +577,7 @@ public function header($header = null, $value = null) {
if (is_numeric($header)) {
list($header, $value) = array($value, null);
}
if ($value === null) {
if ($value === null && strpos($header, ':') !== false) {
list($header, $value) = explode(':', $header, 2);
}
$this->_headers[$header] = is_array($value) ? array_map('trim', $value) : trim($value);
@@ -164,11 +164,15 @@ public function testHeader() {
$headers += array('Location' => 'http://example.com');
$this->assertEquals($headers, $response->header());
//Headers with the same name are overwritten
// Headers with the same name are overwritten
$response->header('Location', 'http://example2.com');
$headers = array('Location' => 'http://example2.com');
$this->assertEquals($headers, $response->header());
$response->header('Date', null);
$headers += array('Date' => null);
$this->assertEquals($headers, $response->header());
$response->header(array('WWW-Authenticate' => 'Negotiate'));
$headers += array('WWW-Authenticate' => 'Negotiate');
$this->assertEquals($headers, $response->header());

0 comments on commit 4e1b601

Please sign in to comment.
You can’t perform that action at this time.