You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
upgrade header leads to 400 Invalid Upgrade Request #3813
Currently we return a 400 Invalid Upgrade Request when the request contains the upgrade headers:
"Connection: Upgrade, HTTP2-Settings"
"Upgrade: h2c"
"HTTP2-Settings: ...
If I'm reading the RFC right (https://tools.ietf.org/html/rfc7540#section-3.2), if we don't support h2, we can just ignore it, returning a 200 instead of giving an error. Since we don't see 400s in production that often, I assume this isn't that common for clients. I noticed it in trying to set up a thousand eyes (a RUM monitoring 3rd party service) test -- they do it by default. The error is reproducible on:
http requests with these headers (always)
https requests with these headers when http2 was not negotiated in ALPN
IIUC, the h2c is only used on http requests, id est cleartext. It is an error to attempt to upgrade with an h2c request when it was not negotiated in the ALPN.
But you are correct about the cleartext scenario. If they attempt to upgrade and we don't support it, we can simply reply as though it wasn't there.
@masaori335@maskit I did see some code related to h2c, for example, HttpTransact::build_upgrade_response but it is not used anywhere. Is h2c a WIP or this issue a bug?
Upgrading to h2c is not supported now. At the very beginning we supported h2c once but we dropped it because major clients don’t support it. So the code for h2c is not maintained. We can remove the code but it might be possible to support h2c again with small changes if somebody need it. This is a reason the code is left.
As for 400, it’s not h2c specific behavior IIRC. The same thing happens with WebSocket. So just ignoring Upgrade header would not be an appropriate behavior in some use cases. It depends on endpoints (requested paths).
I am fine with returning 200 for h2c case. However, the status code 400 is come from a logic for Upgrade header handler that is also used for WebSocket, IIRC. So we can't change the logic without checking WebSocket spec. It might say something different.
Activity
[-]upgrade header leads to 400 when h2 not supported[/-][+]upgrade header leads to 400 Invalid Upgrade Request[/+]alficles commentedon Jun 11, 2018
IIUC, the h2c is only used on http requests, id est cleartext. It is an error to attempt to upgrade with an h2c request when it was not negotiated in the ALPN.
But you are correct about the cleartext scenario. If they attempt to upgrade and we don't support it, we can simply reply as though it wasn't there.
zizhong commentedon Jul 25, 2018
@masaori335 @maskit I did see some code related to h2c, for example,
HttpTransact::build_upgrade_responsebut it is not used anywhere. Is h2c a WIP or this issue a bug?maskit commentedon Jul 25, 2018
Upgrading to h2c is not supported now. At the very beginning we supported h2c once but we dropped it because major clients don’t support it. So the code for h2c is not maintained. We can remove the code but it might be possible to support h2c again with small changes if somebody need it. This is a reason the code is left.
As for 400, it’s not h2c specific behavior IIRC. The same thing happens with WebSocket. So just ignoring Upgrade header would not be an appropriate behavior in some use cases. It depends on endpoints (requested paths).
zwoop commentedon May 23, 2019
I agree with the OP, if the server doesn't support HTTP/2, it can ignore the Upgrade: h2 or Upgrade: h2c options, and return 200 OK.
kib commentedon Jun 4, 2019
From RFC750 https://tools.ietf.org/html/rfc7540#section-3.2
and also (to react to @zwoop a bit more precise)
maskit commentedon Jun 5, 2019
I am fine with returning 200 for h2c case. However, the status code 400 is come from a logic for Upgrade header handler that is also used for WebSocket, IIRC. So we can't change the logic without checking WebSocket spec. It might say something different.