h2 icon indicating copy to clipboard operation
h2 copied to clipboard

Feat: Add a feature flag to ignore connection headers

Open eaufavor opened this issue 2 years ago • 5 comments

According to the RFC, when encountering connection headers, H2 should treat them as protocol errors. However, in reality there are servers just setting these headers but only for informational purpose.

This feature allow the receiving end to just ignore these headers without bailing the entire stream.

I'm just putting this out here to see whether it is possible for things like this to be accepted.

eaufavor avatar Aug 15 '23 00:08 eaufavor

Are there any other widely used implementations that support this? I initially think the pressure should instead be pushed back onto those servers to change, since weakening the implementations is how HTTP/1.1 got to have so many edge cases.

seanmonstar avatar Aug 15 '23 13:08 seanmonstar

Good question. I've test a few user agents: The server: nginx conf

location /test_h2_header/ {
   add_header connection "keep-alive";
   return 200 "hello"
}

https://origin.eaufavor.net/test_h2_header/

  • Chrome via h2: accepts the connection header (the header shows in network debug tab), no error.
  • Firefox via h2: ignores the header (not in the network debug tab), no error. Interestingly it also shows that "Connection: keep-alive" is sent by Firefox as a request header (~if we trust it own debug tool~ but it doesn't actually send it per my test on the server side).
  • Curl: stream error.

I have not yet tested other connection headers.

eaufavor avatar Aug 15 '23 15:08 eaufavor

Why is "CI / Check MSRV (pull_request)" failing?

nox avatar Sep 18 '23 14:09 nox

This https://github.com/hyperium/h2/pull/708?

eaufavor avatar Sep 19 '23 20:09 eaufavor

Ah, could you rebase then?

nox avatar Sep 19 '23 21:09 nox