Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient] Add support for HTTP/3 #58331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hostep opened this issue Sep 20, 2024 · 3 comments · Fixed by #59370
Closed

[HttpClient] Add support for HTTP/3 #58331

hostep opened this issue Sep 20, 2024 · 3 comments · Fixed by #59370

Comments

@hostep
Copy link

hostep commented Sep 20, 2024

Description

HTTP/3 is the successor of HTTP/2 and is slowly being used more and more on the web.

It would be nice if HttpClient could support it, currently it only supports up to version 2 in the curl client as far as I can see: https://github.com/symfony/http-client/blob/2af7c5a46eb26bd81a35617e3b198abecd994066/CurlHttpClient.php#L140-L146
Ideally it should try to use HTTP/3 by default if http_version is not provided in the config and when your system supports it.

Thanks!

Example

No response

@stof
Copy link
Member

stof commented Sep 20, 2024

If you don't specify the http_version at all, the curl client will let curl decide which version it uses.

@hostep
Copy link
Author

hostep commented Sep 20, 2024

That doesn't seem to be the case from my findings. Or at least, it won't prefer HTTP/3 over HTTP/2.

On cli:

$ curl -I https://www.denotenshop.nl/
HTTP/2 200

$ curl --http3 -I https://www.denotenshop.nl/
HTTP/3 200

So it's not the default one even if the website supports it.

Same thing in PHP:

use Symfony\Component\HttpClient\CurlHttpClient;

$httpClient = new CurlHttpClient();
$httpResponse = $httpClient->request('GET', 'https://www.denotenshop.nl/');
$httpResponse->getHeaders();
print_r($httpResponse->getInfo());

Results in following output:

Array
(
    [response_headers] => Array
        (
            [0] => HTTP/2 200
            [1] => server: nginx
...

Changing versions in the options works, but not for version '3.0' because there is no support yet in the http client:

$httpResponse = $httpClient->request('GET', 'https://www.denotenshop.nl/', ['http_version' => '1.1']);
// => output: HTTP/1.1 200 OK
$httpResponse = $httpClient->request('GET', 'https://www.denotenshop.nl/', ['http_version' => '2.0']);
// => output: HTTP/2 200
$httpResponse = $httpClient->request('GET', 'https://www.denotenshop.nl/', ['http_version' => '3.0']);
// => output: HTTP/2 200

And yes, my curl in php is seen as being compatible with HTTP/3:

$ php -i | grep -A30 curl
--
curl

cURL Information => 8.9.1
...
HTTP3 => Yes
...
--

@hostep
Copy link
Author

hostep commented Sep 20, 2024

Or maybe we should wait with implementing it until curl no longer considers the feature to be experimental, maybe they will change the default/fallback logic later on when they consider the implementation stable...

Update: found this thread, so probably we'll have to wait until PHP 8.4 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants