zendframework / zend-http

Http component from Zend Framework
BSD 3-Clause "New" or "Revised" License
134 stars 85 forks source link

fix header missed value exception #117

Closed necromant2005 closed 7 years ago

necromant2005 commented 7 years ago

Headers failing by sending empty "user-agent" The main issue in Headers::addHeaders

if (is_string($value)) {
   $this->addHeaderLine($value);

But below in method addHeaderLine signature

    public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null)
    {
        $matches = null;
        if (preg_match('/^(?P<name>[^()><@,;:\"\\/\[\]?=}{ \t]+):.*$/', $headerFieldNameOrLine, $matches)
            && $fieldValue === null) {
            // is a header
            $headerName = $matches['name'];
            $headerKey  = static::createKey($matches['name']);
            $line = $headerFieldNameOrLine;
        } elseif ($fieldValue === null) {
            throw new Exception\InvalidArgumentException('A field name was provided without a field value');
        }

Witch is wrong typing NULL on string only fields

Xerkus commented 7 years ago

As noted in #116 no value headers are invalid