Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suport HTTP Protocol Upgrade Mechanism #291

Open
qqvm opened this issue Jun 22, 2021 · 7 comments
Open

Suport HTTP Protocol Upgrade Mechanism #291

qqvm opened this issue Jun 22, 2021 · 7 comments

Comments

@qqvm
Copy link

qqvm commented Jun 22, 2021

Is there a possibility to upgrade existing HTTP/1 connection to HTTP/2 on the server side?
Mozilla Doc about "Protocol Upgrade": https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade

@Lukasa
Copy link
Contributor

Lukasa commented Jun 22, 2021

We've never implemented support for it, and in practice the plaintext upgrade functionality was essentially never deployed. In fact, it's being removed from the revision of the specification for HTTP/2 because of how little it was used.

@qqvm
Copy link
Author

qqvm commented Jun 22, 2021

I am trying to do that manually, and streamChannel does not get initialized with my final handler. But handshake and settings exchange are successful.

@Lukasa
Copy link
Contributor

Lukasa commented Jun 22, 2021

Can you show me what your pipeline setup looks like?

@qqvm
Copy link
Author

qqvm commented Jun 22, 2021

I have something like this:

self.deleteAllHandlers(context)

context.channel.configureHTTP2Pipeline(mode: .server) { streamChannel -> EventLoopFuture<Void> in
    print("configureHTTP2Pipeline triggered")
    return streamChannel.pipeline.addHandler(HTTP2FramePayloadToHTTP1ServerCodec(normalizeHTTPHeaders: true)).flatMap { () -> EventLoopFuture<Void> in
        streamChannel.pipeline.addHandler(PlainHTTPHandler(fromHTTP2: true)).flatMap { () -> EventLoopFuture<Void> in
            streamChannel.pipeline.addHandler(ErrorHandler())
        }
    }
}.flatMap { (_: HTTP2StreamMultiplexer) in
    context.channel.pipeline.addHandler(ErrorHandler())
}

@Lukasa
Copy link
Contributor

Lukasa commented Jun 23, 2021

And to be clear, this is attempting to do plaintext upgrade?

@qqvm
Copy link
Author

qqvm commented Jun 23, 2021

Yes, this is a plaintext upgrade from HTTP/1.

@Lukasa
Copy link
Contributor

Lukasa commented Jun 23, 2021

Ok, without changes to the core state machine this cannot work. HTTP/2 has a defined upgrade pattern from HTTP/1.1 that requires passing a SETTINGS frame in via a header, and consuming the body payload from the HTTP/1.1 request. You'd need to update the HTTP2Handler and associated state machines in order to get this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants