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

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Header/SetCookie.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
132132
};
133133
}
134134

135-
list($name, $value) = explode(': ', $headerLine, 2);
135+
list($name, $value) = explode(':', $headerLine, 2);
136+
$value = ltrim($value);
136137

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

233234
$value = $this->getValue();

test/Header/SetCookieTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,16 @@ public static function validCookieWithInfoProvider()
334334
),
335335
'myname=myvalue; Expires=Wed, 13-Jan-2021 22:23:01 GMT; Domain=docs.foo.com; Path=/accounts; Secure; HttpOnly'
336336
),
337+
array(
338+
'Set-Cookie:',
339+
array(),
340+
''
341+
),
342+
array(
343+
'Set-Cookie: ',
344+
array(),
345+
''
346+
),
337347
);
338348
}
339-
340349
}

0 commit comments

Comments
 (0)