关于http:http头部字段hopbyhop-headers-vs-endtoend-headers

67次阅读

共计 1578 个字符,预计需要花费 4 分钟才能阅读完成。

一、起源


在看 RFC 文档的时候,看到 hop-by-hop 这个词,有点纳闷,所以开掘了下它的相干含意。

二、含意

hop 是跳,hop-by-hop 是逐跳的意思。end-to-end 则是端到端。这两者都是 http 的头部字段。

1、含意原文

13.5.1 End-to-end and Hop-by-hop Headers
For the purpose of defining the behavior of caches and non-caching proxies, we divide HTTP headers into two categories:
End-to-end headers, which must be transmitted to the ultimate recipient of a request or response. End-to-end headers in responses must be stored as part of a cache entry and transmitted in any response formed from a cache entry.
Hop-by-hop headers, which are meaningful only for a single transport-level connection, and are not stored by caches or forwarded by proxies.
The following HTTP/1.1 headers are hop-by-hop headers:
Connection
Keep-Alive
Public
Proxy-Authenticate
Transfer-Encoding
Upgrade
All other headers defined by HTTP/1.1 are end-to-end headers.
Hop-by-hop headers introduced in future versions of HTTP MUST be listed in a Connection header, as described in section 14.10.
起源:https://www.freesoft.org/CIE/…

[翻译]13.5.1 端到端和逐跳报头

为了定义缓存和非缓存代理的行为,咱们将 HTTP 标头分为两类:
End-to-end headers,必须传输到申请或响应的最终接收者。响应中的端到端标头必须作为缓存条目标一部分存储,并在从缓存条目造成的任何响应中传输。
Hop-by-hop headers,仅对单个传输级连贯有意义,不禁缓存存储或由代理转发。
以下 HTTP/1.1 标头是逐跳标头:
Connection
Keep-Alive
Public
Proxy-Authenticate
Transfer-Encoding
Upgrade
HTTP/1.1 定义的所有其余标头都是端到端标头。
如第 14.10 节所述,在将来版本的 HTTP 中引入的逐跳标头必须列在连贯标头中。

三、http 连贯和 tcp 连贯的区别

一个 http 连贯来回能够包含多个端。比方浏览器发动的申请,先达到服务器宿主机的 nginx,而后达到 docker 容器的 nginx(真正的 web 服务器)。
end-to-end 的头部会被两头的代理照样转发。比方申请头的 host 字段,个别会一成不变的传递到容器的 nginx。
而 hop-by-bop 的头部仅在以后 tcp 连贯中失效。也就是只在浏览器到宿主机 nginx 之间失效,如果宿主机和容器的 nginx 没设置,则不会失效。
也就是说,即便浏览器的申请携带了 connection: keep-alive,也只示意浏览器到宿主机的 nginx 之间的长连贯,但宿主机 nginx 到容器 nginx 是否是长连贯,则须要具体分析了。

参考链接:
https://datatracker.ietf.org/…
https://cloud.tencent.com/dev…

正文完
 0