Icicle\Http\Driver\Builder\Http1Builder::buildOutgoingResponse PHP Метод

buildOutgoingResponse() публичный Метод

public buildOutgoingResponse ( Response $response, Request $request = null, float $timeout, boolean $allowPersistent = false ) : Generator
$response Response
$request Request
$timeout float
$allowPersistent boolean
Результат Generator
    public function buildOutgoingResponse(Response $response, Request $request = null, float $timeout = 0, bool $allowPersistent = false) : \Generator
    {
        if ('upgrade' === strtolower($response->getHeader('Connection'))) {
            return $response;
        }
        if ($allowPersistent && null !== $request && 'keep-alive' === strtolower($request->getHeader('Connection'))) {
            $response = $response->withHeader('Connection', 'keep-alive')->withHeader('Keep-Alive', sprintf('timeout=%d, max=%d', $this->keepAliveTimeout, $this->keepAliveMax));
        } else {
            $response = $response->withHeader('Connection', 'close');
        }
        $response = $response->withoutHeader('Content-Encoding');
        if ($this->compressionEnabled && null !== $request && $request->hasHeader('Accept-Encoding') && $response->hasHeader('Content-Type') && preg_match('/gzip|deflate/i', $request->getHeader('Accept-Encoding'), $matches)) {
            $encoding = strtolower($matches[0]);
            $contentType = $response->getHeader('Content-Type');
            foreach ($this->compressTypes as $pattern) {
                if (preg_match($pattern, $contentType)) {
                    $response = $response->withHeader('Content-Encoding', $encoding);
                    break;
                }
            }
        }
        return yield from $this->buildOutgoingStream($response, $timeout);
    }