Skip to content

HTTP2 support  #1237

Description

@risacher

Now that HTTP2 is in core, it should be supported by node-http-proxy.

My initial efforts to try to make this work result in the following errror:

_http_outgoing.js:490
    throw new TypeError(`Header name must be a valid HTTP Token ["${name}"]`);
    ^

TypeError: Header name must be a valid HTTP Token [":path"]

I think this is because in http-proxy/lib/http-proxy/common.js, setupOutgoing() is basically copying headers from the incoming request to the outgoing request, and HTTP2 headers start with colons, but HTTP1 headers cannot.

Activity

  1. risacher commented on Feb 23, 2018

    @risacher
    Author

    q.v. https://tools.ietf.org/html/rfc7540#section-8.1.2.3

    This has some specific guidance on how to convert HTTP/2 pseudo headers into HTTP/1.1 headers. E.g. "An intermediary that converts an HTTP/2 request to HTTP/1.1 MUST create a Host header field if one is not present in a request by copying the value of the ":authority" pseudo-header field."

  2. safizn commented on Mar 23, 2018

    @safizn

    You could check maybe Redbird implementation of it. https://github.com/OptimalBits/redbird

  3. risacher commented on Mar 23, 2018

    @risacher
    Author

    Interesting. From what I can tell, Redbird uses the 'spdy' module in place of the https module if HTTP/2 is enabled, and apparently that's sufficient. The relevant code from redbird/proxy.js is this:

    if (sslOpts.http2) {
        https = sslOpts.serverModule || require('spdy');
        if(_.isObject(sslOpts.http2)){
          sslOpts.spdy = sslOpts.http2;
        }
      } else {
        https = sslOpts.serverModule || require('https');
      }
    
  4. nadeemkhedr commented on Apr 17, 2018

    @nadeemkhedr

    +1

  5. skerit commented on Jul 5, 2018

    @skerit

    Nice, I didn't know the spdy module could be used as a drop-in replacement for https, but unfortunately it's no longer being maintained.

  6. risacher commented on Dec 10, 2018

    @risacher
    Author

    spdy apparently does not work for node versions above 10.5, so its suitability as a workaround is diminishing.

  7. risacher commented on Feb 4, 2019

    @risacher
    Author
  8. ashubham commented on Nov 5, 2020

    @ashubham
    Contributor

    Any updates here ?

  9. zhe-he commented on Dec 18, 2023

    @zhe-he

    Can it support HTTP/3.0? (I'm not a devil)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions