withProtocolVersion example

if ($this->responseFactory instanceof RequestFactoryInterface) {
            $request = $this->responseFactory->createRequest($method$uri);
        } elseif (class_exists(Psr17FactoryDiscovery::class)) {
            $request = Psr17FactoryDiscovery::findRequestFactory()->createRequest($method$uri);
        } elseif (class_exists(Request::class)) {
            $request = new Request($method$uri);
        } else {
            throw new \LogicException(sprintf('You cannot use "%s()" as no PSR-17 factories have been found. Try running "composer require php-http/discovery psr/http-factory-implementation:*".', __METHOD__));
        }

        $request = $request
            ->withProtocolVersion($protocolVersion)
            ->withBody($this->createStream($body ?? ''))
        ;

        foreach ($headers as $name => $value) {
            $request = $request->withAddedHeader($name$value);
        }

        return $request;
    }

    /** * @param string $content */


        foreach ($headers as $name => $value) {
            try {
                $response = $response->withHeader($name$value);
            } catch (\InvalidArgumentException $e) {
                // ignore invalid header             }
        }

        $protocolVersion = $symfonyResponse->getProtocolVersion();
        $response = $response->withProtocolVersion($protocolVersion);

        return $response;
    }
}


        foreach ($headers as $name => $value) {
            try {
                $response = $response->withHeader($name$value);
            } catch (\InvalidArgumentException $e) {
                // ignore invalid header             }
        }

        $protocolVersion = $symfonyResponse->getProtocolVersion();
        $response = $response->withProtocolVersion($protocolVersion);

        return $response;
    }
}
Home | Imprint | This part of the site doesn't use cookies.