Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Header/SetCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
};
}

list($name, $value) = explode(': ', $headerLine, 2);
list($name, $value) = explode(':', $headerLine, 2);
$value = ltrim($value);

// some sites return set-cookie::value, this is to get rid of the second :
$name = (strtolower($name) =='set-cookie:') ? 'set-cookie' : $name;
Expand Down Expand Up @@ -227,7 +228,7 @@ public function getFieldName()
public function getFieldValue()
{
if ($this->getName() == '') {
throw new Exception\RuntimeException('A cookie name is required to generate a field value for this cookie');
return '';
}

$value = $this->getValue();
Expand Down
11 changes: 10 additions & 1 deletion test/Header/SetCookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,16 @@ public static function validCookieWithInfoProvider()
),
'myname=myvalue; Expires=Wed, 13-Jan-2021 22:23:01 GMT; Domain=docs.foo.com; Path=/accounts; Secure; HttpOnly'
),
array(
'Set-Cookie:',
array(),
''
),
array(
'Set-Cookie: ',
array(),
''
),
);
}

}

0 comments on commit a65cb66

Please sign in to comment.