How do you determine which version of the HTTP protocol to use when building the HTTP request line?

The current mainstream HTTP protocol versions are HTTP/1.1, HTTP/2, HTTP/3 (experimental). The specific version used when the request occurs is determined by the client, and the client and the server negotiate together.

For example, a client that supports HTTP/2 will indicate that it supports h2 and http/1.1 in the ALPN (Application-Layer Protocol Negotiation) extension when the TLS handshake is initiated, and you can see the following by opening the debug mode of the curl command:

v2-9761b575792ce534283ac598cf801669_720wv2-9761b575792ce534283ac598cf801669_720w

If the server also supports h2, it will tell the client:

v2-1c91d6ec64e4c20d634b131409691a3e_720wv2-1c91d6ec64e4c20d634b131409691a3e_720w

Not supported will also tell:

v2-ce0863ed0659484b40113700c50410fb_720wv2-ce0863ed0659484b40113700c50410fb_720w

The same is true for browsers using HTTP/2. But HTTP/3 uses UDP, and UDP doesn’t need a handshake, so it can’t be negotiated in the same way as HTTP/2. Instead, the request is made according to ordinary HTTP 1.1/2 at first, and the server tells the client from the response header (alt-svc) of these requests that it supports h3. This way if the client also supports h3. You can use h3 directly in future requests, and ma is max-age, which means you have to forget that this domain name supports h3 after this time.

The post How do I determine what version of the HTTP protocol to use when building the HTTP request line? first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9675
This site is for inclusion only, and the copyright belongs to the original author.