http1.1 to http/2 what about version header and ot

2019-07-08 10:50发布

In http 1.1, the status line was

scheme/version code reason
HTTP/1.1 200 OK

I see :scheme and :status headers in 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 on https for http2, 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 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).

thanks, Dean

标签: http2
1条回答
在下西门庆
2楼-- · 2019-07-08 11:19

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.

查看更多
登录 后发表回答