Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit a10dcfc174b8b867c8b48eab35ef51bc68041f55 1 parent 4ee64b9
@rsandrea authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  library/Zend/Http/Header/UserAgent.php
2  library/Zend/Http/Header/UserAgent.php
@@ -16,7 +16,7 @@ public static function fromString($headerLine)
list($name, $value) = preg_split('#: #', $headerLine, 2);
// check to ensure proper header type for this factory
- if (strtolower($name) !== 'user-agent') {
+ if (str_replace(array('_', ' ', '.'), '-', strtolower($name)) !== 'user-agent') {
throw new Exception\InvalidArgumentException('Invalid header line for User-Agent string');
Please sign in to comment.
Something went wrong with that request. Please try again.