src/net/http/HeaderParser.php
public function parseLine($line) {
        $line = trim($line, "\r\n");

        if (preg_match('/^([\w-]+):\s+(.+)/', $line, $matches)) {
            $name = strtolower($matches[1]);
            $value = $matches[2];
            $this->currentHeader = $name;

            if (isset($this->headers[$name])) {
                if (!is_array($this->headers[$name])) {
                    $this->headers[$name] = [$this->headers[$name]];
                }
                $this->headers[$name][] = $value;
            }
            else {
                $this->headers[$name] = $value;
            }
        }
        elseif (preg_match('/^\s+(.+)$/', $line, $matches) && $this->currentHeader !== null) {
            if (is_array($this->headers[$this->currentHeader])) {
                $lastKey = sizeof($this->headers[$this->currentHeader]) - 1;
                $this->headers[$this->currentHeader][$lastKey] .= $matches[1];
            }
            else {
                $this->headers[$this->currentHeader] .= $matches[1];
            }
        }

        return $this;
    }
public function parseLine($line) {
        $line = trim($line, "\r\n");

        if (preg_match('/^([\w-]+):\s+(.+)/', $line, $matches)) {
            $name = strtolower($matches[1]);
            $value = $matches[2];
            $this->currentHeader = $name;

            if (isset($this->headers[$name])) {
                if (!is_array($this->headers[$name])) {
                    $this->headers[$name] = [$this->headers[$name]];
                }
                $this->headers[$name][] = $value;
            }
            else {
                $this->headers[$name] = $value;
            }
        }
        elseif (preg_match('/^\s+(.+)$/', $line, $matches) && $this->currentHeader !== null) {
            if (is_array($this->headers[$this->currentHeader])) {
                $lastKey = sizeof($this->headers[$this->currentHeader]) - 1;
                $this->headers[$this->currentHeader][$lastKey] .= $matches[1];
            }
            else {
                $this->headers[$this->currentHeader] .= $matches[1];
            }
        }

        return $this;
    }
public function parseLine ( $ line ) { $ line = trim ( $ line , "\r\n" ) ; if ( preg_match ( '/^([\w-]+):\s+(.+)/' , $ line , $ matches ) ) { $ name = strtolower ( $ matches [ 1 ] ) ; $ value = $ matches [ 2 ] ; $ this -> currentHeader = $ name ; if ( isset ( $ this -> headers [ $ name ] ) ) { if ( ! is_array ( $ this -> headers [ $ name ] ) ) { $ this -> headers [ $ name ] = [ $ this -> headers [ $ name ] ] ; } $ this -> headers [ $ name ] [ ] = $ value ; } else { $ this -> headers [ $ name ] = $ value ; } } elseif ( preg_match ( '/^\s+(.+)$/' , $ line , $ matches ) && $ this -> currentHeader !== null ) { if ( is_array ( $ this -> headers [ $ this -> currentHeader ] ) ) { $ lastKey = sizeof ( $ this -> headers [ $ this -> currentHeader ] ) - 1 ; $ this -> headers [ $ this -> currentHeader ] [ $ lastKey ] .= $ matches [ 1 ] ; } else { $ this -> headers [ $ this -> currentHeader ] .= $ matches [ 1 ] ; } } return $ this ; }
Parst eine einzelne Headerzeile.

@param  string $line - Headerzeile

@return $this
Parst eine einzelne Headerzeile .