Icicle\Http\Driver\Reader\Http1Reader::readHeaders PHP Метод

readHeaders() защищенный Метод

protected readHeaders ( Icicle\Stream\Structures\Buffer $buffer, Icicle\Socket\Socket $socket, float $timeout ) : Generator
$buffer Icicle\Stream\Structures\Buffer
$socket Icicle\Socket\Socket
$timeout float
Результат Generator
    protected function readHeaders(Buffer $buffer, Socket $socket, float $timeout = 0) : \Generator
    {
        $size = 0;
        $headers = [];
        do {
            while (false === ($position = $buffer->search("\r\n"))) {
                if ($buffer->getLength() >= $this->maxSize) {
                    throw new MessageException(Response::REQUEST_HEADER_TOO_LARGE, sprintf('Message header exceeded maximum size of %d bytes.', $this->maxSize));
                }
                $buffer->push(yield from $socket->read(0, null, $timeout));
            }
            $length = $position + 2;
            $line = $buffer->shift($length);
            if (2 === $length) {
                return $headers;
            }
            $size += $length;
            $parts = explode(':', $line, 2);
            if (2 !== count($parts)) {
                throw new ParseException('Found header without colon.');
            }
            list($name, $value) = $parts;
            $name = Message\decode($name);
            $value = Message\decode(trim($value));
            // No check for case as Message class will automatically combine similarly named headers.
            if (!isset($headers[$name])) {
                $headers[$name] = [$value];
            } else {
                $headers[$name][] = $value;
            }
        } while ($size < $this->maxSize);
        throw new MessageException(Response::REQUEST_HEADER_TOO_LARGE, sprintf('Message header exceeded maximum size of %d bytes.', $this->maxSize));
    }