在 hpack 的 RFC 中,它这样说...
The dynamic table can contain duplicate entries (i.e., entries with the same name and same value). Therefore, duplicate entries MUST NOT be treated as an error by a decoder
在表中,由于静态表和动态表是一个(通过 RFC 中的索引地址空间),这是否意味着如果我在索引 75 中有 header: headername: headervalue,那么我在新请求中遇到它,我还应该将它添加到动态表中,尽管它已经位于索引 75 处?如果是这样,我会参考哪一个,索引 75 还是最新索引?那么,如果我遇到具有相同名称但每个请求都有新值的标头,会发生什么情况,我可以在动态表中保留永不更改的标头名称,然后使用该索引仅解码标头名称吗?
in the RFC for hpack, it says this...
The dynamic table can contain duplicate entries (i.e., entries with the same name and same value). Therefore, duplicate entries MUST NOT be treated as an error by a decoder
in the table, since the static and dynamic table are one (via index address space in RFC), does this mean if i have the header: headername: headervalue in index 75, then i encounter it in a new request, i should also add it to the dynamic table although its already at index 75? If so, which one would i reference, index 75 or the newest index? Then, what happens if i encounter a header that has the same name but with each request has a new value, can i keep the header name that never changes in the dynamic table then use that index to decode the header name only?
发布评论
评论(1)
理想情况下,您不应该。这样做是浪费空间。但是,如果您愿意,也可以做到这一点,并且也有充分的理由。
您可以使用任何一个。每个都是同样有效的。
实际上,Web浏览器有时如此问题所示,有时以不同的方式实现此目的:怪异2在Firefox中编码的HPACK
是的,你可以。理想情况下,将使用 nofollow noreferrer“防止他们用无用的一次性值填充动态表。但是,这也意味着标题名称也不会被索引,因此您无法按照您希望的那样看待。
Ideally you shouldn’t. It’s a waste of space to do that. But you CAN do that if you want to and have a good reason too.
You can use either one. Each is equally valid.
And in fact web browsers sometimes implement this differently as illustrated in this question: Weird HTTP/2 HPACK encoding in Firefox
Yes you could. Ideally such fields would be sent with Literal Header Field without Indexing (or the similar Literal Header Field Never Indexed) syntax to prevent them filling up the dynamic table with useless, single-use values. However, that would also mean the header name would also not be indexed so you couldn’t look just that up as you hoped.