mojo icon indicating copy to clipboard operation
mojo copied to clipboard

HTTP/2 and HTTP/3

Open kraih opened this issue 12 years ago • 45 comments

The final HTTP/2 spec is still at least 1-2 years away, but now that the first draft (based on SPDY) has been released, i believe we can at least start planning our implementation.

http://tools.ietf.org/html/draft-ietf-httpbis-http2-00

While details like the upgrade mechanism from HTTP/1.1 and mandatory TLS encryption are very likely to change, major features like multiplexing are pretty much a given, and will require some refactoring in Mojolicious.

kraih avatar Dec 02 '12 11:12 kraih

I've been thinking about this a bit, and i believe a new layer (Mojo::Channel?) between connection management and high level transactions would make adding new protocols and dealing with multiplexing a lot easier.

Mojo::UserAgent      -> Mojo::Channel::HTTP::Client      -> Mojo::Transaction::HTTP
                     -> Mojo::Channel::WebSocket::Client -> Mojo::Transaction::WebSocket

Mojo::Server::Daemon -> Mojo::Channel::HTTP::Server      -> Mojo::Transaction::HTTP
                     -> Mojo::Channel::WebSocket::Server -> Mojo::Transaction::WebSocket

Channels could combine all client_* and server_* methods from the transaction classes with the transaction management code of the user agent and daemon.

kraih avatar Dec 02 '12 12:12 kraih

A good first step might be to move the transaction management code from Mojo::UserAgent to Mojo::Channel::HTTP::Client and Mojo::Channel::WebSocket::Client, that should be enough to figure out the right API and cause no backwards compatibility issues.

kraih avatar Dec 16 '12 02:12 kraih

+1

ChinaXing avatar Jun 14 '13 06:06 ChinaXing

:+1:

derbrown avatar Apr 02 '14 20:04 derbrown

The current version of the HTTP/2 spec terrifies me, think we'll wait with this as long as we can.

kraih avatar May 30 '14 02:05 kraih

I believe the original Mojo::Channel plan might also have also been a bit too ambitious, better start with something that fits into the current architecture, and work on abstraction once we have more experience.

kraih avatar Jul 06 '14 16:07 kraih

The HTTP/1 upgrade mechanism can be ignored completely, browser vendors are not going to implement that (Firefox and Chrome have confirmed this in the working group), only valid handshake for negotiating HTTP/2 will be TLS with ALPN/NPN. So IO::Socket::SSL and a modern version of OpenSSL will be hard requirements.

kraih avatar Jul 07 '14 00:07 kraih

Working Group Last Call. http://lists.w3.org/Archives/Public/ietf-http-wg/2014JulSep/1563.html

kraih avatar Aug 01 '14 01:08 kraih

We need more volunteers to work on this.

kraih avatar Dec 08 '14 03:12 kraih

I can help!

dvinciguerra avatar Dec 08 '14 04:12 dvinciguerra

The plans i've outlined above were a bit too ambitious, that extra layer of abstraction is not really necessary. I think a good first step would be to start with a prototype, using an existing implementation of the HTTP/2 protocol (perhaps Protocol::HTTP2). Then the focus can be on getting protocol negotiation right, with NPN/ALPN in Mojo::IOLoop::Client/Mojo::IOLoop::Server, and HTTP1/HTTP2 in Mojo::UserAgent/Mojo::Server::Daemon.

I'm actually not too concerned about the actual protocol implementation, that seems pretty straight forward, and more about the integration into our existing architecture.

kraih avatar Dec 08 '14 04:12 kraih

Since browsers like Chrome already support HTTP/2, i think a good first milestone would be to add NPN/ALPN support to Mojo::IOLoop::Server with IO::Socket::SSL, and then just enough Protocol::HTTP2 glue code to Mojo::Server::Daemon for basic request/response handling.

kraih avatar Dec 08 '14 05:12 kraih

The HTTP/2 spec was just finalized, and OpenSSL 1.0.2 with ALPN support has been released too. So theoretically nothing is stopping this feature anymore.

kraih avatar Feb 19 '15 02:02 kraih

:+1:

kberov avatar Feb 19 '15 23:02 kberov

I don't familiar with Mojo internals, but i tried to implement glue code https://github.com/vlet/mojo/tree/vlet/http2-hacks Protocol::HTTP2 API is not stable yet, so there is a opportunity to change it in a way, that will be convenient for Mojo

vlet avatar Apr 01 '15 08:04 vlet

@vlet Thanks, that's a pretty decent proof of concept. The PSGI step should be avoided though, and the response might not be available right after the request event has been emitted (non-blocking operations in progress).

kraih avatar Apr 01 '15 15:04 kraih

Up ;) Would be great to have this implemented :)

rwx-zwx-awx avatar Sep 07 '15 09:09 rwx-zwx-awx

This feature depends on #876.

kraih avatar Nov 21 '15 02:11 kraih

This feature also depends on #888.

kraih avatar Dec 15 '15 18:12 kraih

Perhaps I'm naive, but I feel like if Mojolicious was first or among the first to release HTTP/2 support that it might help it to gain some attention and even many more new users.

s1037989 avatar Jan 07 '16 02:01 s1037989

Sadly we are already pretty far behind with this.

kraih avatar Jan 07 '16 02:01 kraih

Honestly, i think unless we find a sponsor for this feature, it will take a very long time to get it production ready.

kraih avatar Jan 07 '16 03:01 kraih

I imagine this might become a bigger topic once there are HTTP/2 only servers on the web, and folks want to access them with Mojo::UserAgent.

kraih avatar Jan 07 '16 03:01 kraih

What is needed from a sponsor? I don't have a ton of connections but I'd be happy to spread the word as best I can, as I already do for Mojolicious. Everyone in St. Louis, MO, USA is at least now aware that Mojolicious exists and is the greatest thing since sliced bread. :D

I'd also like to get my employer involved, so there's that...

Is there anything more that a sponsor can do than provide money? How much money? What is the process for this? Is there perhaps a not-for-profit entity for the purpose of tax deductible contributions (in the USA and/or otherwise)? I could look into establishing a not-for-profit organization in the USA if interested, I'm unaware at this point what the requirements of it are.

What would be the timeline to release a first version of this branch?

s1037989 avatar Jan 07 '16 05:01 s1037989

Realistically, i think it would take a good full-time programmer between 6 and 12 months to finish this feature. Currently there is no formal process, but if one or more interested companies step up, i'm sure we can change that pretty quickly.

There are a few milestones to reach, 1) protocols like HTTP/1.1 and WebSockets need to become pluggable (#876), 2) we need ALPN protocol negotiation (#888), 3) proof of concept implementation of the HTTP/2 protocol with an existing CPAN module like Protocol::HTTP2, 4) optimized custom implementation of the HTTP/2 protocol, 5) advanced features such as stream prioritization and server push.

kraih avatar Jan 07 '16 14:01 kraih

After the very successful hackathon last weekend, i think 6 months is a very realistic timeframe.

kraih avatar Jan 12 '16 23:01 kraih

For learning more about HTTP/2, i recommend these two free ebooks.

https://www.nginx.com/http2-ebook/ http://daniel.haxx.se/http2/

kraih avatar Jan 13 '16 16:01 kraih

:+1: Thanks for the links!

kberov avatar Jan 13 '16 16:01 kberov

I would be happy to sponsor some dev time towards this.

evoyy avatar Jan 26 '16 21:01 evoyy

ALPN support is done (#888), and pluggable protocols almost finished too (#876). I think a proof of concept HTTP/2 implementation might be possible now.

kraih avatar Mar 01 '16 03:03 kraih