python-hyper / h11

A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
https://h11.readthedocs.io/
MIT License
490 stars 62 forks source link

Joining efforts with the CherryPy team #84

Closed webknjaz closed 4 years ago

webknjaz commented 5 years ago

Hi,

I'm one of the maintainers of CherryPy. Currently, we have a subproject which implements HTTP/WSGI server as a separate Python package distribution. It's called Cheroot. It implements own HTTP parsing layer.

Given that having a one good framework-agnostic protocol implementation is one honking great idea, it seems logical to use that instead of supporting own parser. I'm looking forward to seeing how we could integrate h11 and also porting things from Cheroot/CherryPy into h11 in order to have one superior HTTP parser.

Ref: https://github.com/cherrypy/cheroot/issues/201.

I haven't checked h11 deeply so I'm publishing this just to document the intention :)

njsmith commented 5 years ago

Unsurprisingly, I think this would be great :-).

I don't currently know of any changes needed on h11's side; it's already designed to be dropped into a server like CherryPy. There may be some real-world compatibility issues that you flush out, because HTTP/1.1 has many poorly-specified edge cases, but the only unresolved one I know about currently is #31 (h11 doesn't preserve header case) and that's mostly an issue for clients, not servers.

Let us know how it goes!

ian-otto commented 4 years ago

Hey there, I'm one of the developers working on this task and I'm confused about the terminology of this page. According to the page, "h11 only speaks HTTP/1.1", but in that same page, "It can talk to HTTP/1.0 clients and servers".

I'm at a point where our HTTP/1.1 parser is working correctly in tests, but it's failing when the tests initially start with HTTP/1.0 with an error stating that h11 only speaks HTTP/1.1. Is there a workaround to allow h11 to talk to an HTTP/1.0 client that I'm missing?

njsmith commented 4 years ago

HTTP/1.1 is supposed to be backwards compatible with HTTP/1.0, so any correct implementation of HTTP/1.1 should work fine when the other side is speaking HTTP/1.0. Of course, HTTP in the real world doesn't always work the way the standards say it should, so it's possible that we have some bugs here. But I'm not aware of any bugs like that currently. A server using h11 should Just Work when a client speaks HTTP/1.0.

Are you trying to explicitly detect what version the client is using and speak the same version back to it? You don't need to do that.

njsmith commented 4 years ago

Looks like the relevant PR is https://github.com/cherrypy/cheroot/pull/262, and the solution is indeed to just speak HTTP/1.1 even if the peer only speaks HTTP/1.0.

webknjaz commented 4 years ago

Hey, @njsmith! It seems like https://github.com/python-hyper/h11/pull/99 is blocking our progress :(

Any chance you could give a green light there?

webknjaz commented 4 years ago

@njsmith thanks for merging that! Could you please also cut a release so that we could depend on it as published on PyPI?

webknjaz commented 4 years ago

Hey @njsmith, could you please unblock us by releasing the recent changes to PyPI?

pgjones commented 4 years ago

@webknjaz I've released 0.10.0, which should unblock you. Lets find out how h11 works with CherryPy!

webknjaz commented 4 years ago

@pgjones thanks a lot!