PHPDaemon\Servers\WebSocket\Connection::httpReadHeaders PHP Method

httpReadHeaders() protected method

Read headers line-by-line
protected httpReadHeaders ( ) : boolean | null
return boolean | null Success
    protected function httpReadHeaders()
    {
        while (($l = $this->readLine()) !== null) {
            if ($l === '') {
                return true;
            }
            $e = explode(': ', $l);
            if (isset($e[1])) {
                $this->currentHeader = 'HTTP_' . strtoupper(strtr($e[0], Generic::$htr));
                $this->server[$this->currentHeader] = $e[1];
            } elseif (($e[0][0] === "\t" || $e[0][0] === " ") && $this->currentHeader) {
                // multiline header continued
                $this->server[$this->currentHeader] .= $e[0];
            } else {
                // whatever client speaks is not HTTP anymore
                $this->badRequest();
                return false;
            }
        }
        return null;
    }