Skip to content

upgrade header leads to 400 Invalid Upgrade Request #3813

Closed

Description

@mlibbey

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

Activity

  1. changed the title [-]upgrade header leads to 400 when h2 not supported[/-] [+]upgrade header leads to 400 Invalid Upgrade Request[/+] on Jun 11, 2018
  2. alficles commented on Jun 11, 2018

    @alficles
    Contributor

    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.

  3. zizhong commented on Jul 25, 2018

    @zizhong
    Member

    @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?

  4. maskit commented on Jul 25, 2018

    @maskit
    Member

    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).

  5. added this to the 9.1.0 milestone on May 23, 2019
  6. zwoop commented on May 23, 2019

    @zwoop
    Contributor

    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.

  7. kib commented on Jun 4, 2019

    @kib

    From RFC750 https://tools.ietf.org/html/rfc7540#section-3.2

    A server that does not support HTTP/2 can respond to the request as though the Upgrade header field were absent

    and also (to react to @zwoop a bit more precise)

    A server MUST ignore an "h2" token in an Upgrade header field.

  8. maskit commented on Jun 5, 2019

    @maskit
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions