简体   繁体   中英

HTTP1.1 to HTTP/2: what about headers?

In HTTP 1.1, the status line was

scheme/version code reason
HTTP/1.1 200 OK

I see :scheme and :status headers in the HPACK spec. I don't however see anything for version or reason? Is there not one?

In a request in HTTP 1.1, the request line was

method uri scheme/version
POST http://myhost.com HTTP/1.1

I see :method and I see :path, which I think is just a relative path, which is not the same as the full absolute path (and since Chrome and Firefox are pushing HTTPS for HTTP/2, this may make sense). I do not see version header though.

Is there a version header? Or is it seen that this will always be known before the protocol decision such that it is not really needed?

What about reason codes? Is it assumed these are pretty constant so that goes away (I am guessing here)?

In HTTP/1, the version token was needed to differentiate HTTP/1.0 from HTTP/1.1, since they had the same wire representation, but were supporting different features.

For example, a client declaring HTTP/1.1 implicitly tells the server that it supports persistent connections and content chunking.

With HTTP/2, the protocol version is negotiated .

In clear-text HTTP/2, the Upgrade header reports h2c , where the 2 means version 2 of the protocol. I imagine that for HTTP/3 the token will change to h3c . Similarly happens for encrypted HTTP/2 where the token h2 is negotiated via ALPN.

Reason messages have been dropped as being redundant, as the status code was already conveying all the necessary information (not to mention that they could be attack vectors).

For these reasons, HTTP/2 does not have neither version nor reason pseudo-headers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM