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

Commit 5f4d01d

Browse files
committed
The fromString function fail as the http headers returned by $_SERVER variables are of the form HTTP_USER_AGENT.
I do not know if this is the right way to do it, but line 19 won't validate as the headers are cleaned up for the HTTP_ prefix but the _ signs are never replaced by -, hence the validation fail. I took the str_replace(array('_', ' ', '.'), '-', strtolower($name)) idea from the file Zend/Http/Headers.php on line 284 as this is the way the $key variable is created. If anyone finds a better way to do it please message me.

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Header/UserAgent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static function fromString($headerLine)
1616
list($name, $value) = preg_split('#: #', $headerLine, 2);
1717

1818
// check to ensure proper header type for this factory
19-
if (strtolower($name) !== 'user-agent') {
19+
if (str_replace(array('_', ' ', '.'), '-', strtolower($name)) !== 'user-agent') {
2020
throw new Exception\InvalidArgumentException('Invalid header line for User-Agent string');
2121
}
2222

0 commit comments

Comments
 (0)