InformationalChunk example



        Loop::run();

        return null === self::$delay ? 1 : 0;
    }

    private static function generateResponse(Request $request, AmpClientState $multi, string $id, array &$info, array &$headers, CancellationTokenSource $canceller, array &$options, \Closure $onProgress, &$handle, ?LoggerInterface $logger, Promise &$pause): \Generator
    {
        $request->setInformationalResponseHandler(static function DResponse $response) use ($multi$id, &$info, &$headers) {
            self::addResponseHeaders($response$info$headers);
            $multi->handlesActivity[$id][] = new InformationalChunk($response->getStatus()$response->getHeaders());
            self::stopLoop();
        });

        try {
            /* @var Response $response */
            if (null === $response = yield from self::getPushedResponse($request$multi$info$headers$options$logger)) {
                $logger?->info(sprintf('Request: "%s %s"', $info['http_method']$info['url']));

                $response = yield from self::followRedirects($request$multi$info$headers$canceller$options$onProgress$handle$logger$pause);
            }

            
 elseif (303 === $info['http_code'] || ('POST' === $info['http_method'] && \in_array($info['http_code'][301, 302], true))) {
                    curl_setopt($ch, \CURLOPT_POSTFIELDS, '');
                }
            }

            return \strlen($data);
        }

        // End of headers: handle informational responses, redirects, etc.
        if (200 > $statusCode) {
            $multi->handlesActivity[$id][] = new InformationalChunk($statusCode$headers);
            $location = null;

            return \strlen($data);
        }

        $info['redirect_url'] = null;

        if (300 <= $statusCode && $statusCode < 400 && null !== $location) {
            if ($noContent = 303 === $statusCode || ('POST' === $info['http_method'] && \in_array($statusCode[301, 302], true))) {
                $info['http_method'] = 'HEAD' === $info['http_method'] ? 'HEAD' : 'GET';
                curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $info['http_method']);
            }
Home | Imprint | This part of the site doesn't use cookies.