-
Notifications
You must be signed in to change notification settings - Fork 98
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
Feature/http2 prior knowledge #269
Feature/http2 prior knowledge #269
Conversation
Okay, so as mentioned on encode/httpx#1523 I think an |
d42ba7b
to
1e5da3e
Compare
f0bd9b1
to
c4a21de
Compare
I have replaced the I can maybe throw an error if both http1 and http2 are set to False on initialization of the |
Okay, so the thing that'd be really helpful here would be a concrete real-world example of a URL that you'd want to use this against. That'll help us verify what we're doing with an actually use case, rather than "in theory". If you can walk us through exactly what it is you're trying to do in practice, it's a huge help in adequately describing the motivation for any code changes, and helps ground us in real use-cases rather than just indulging in bit wrangling for the sake of it. I started doing a bit more digging into this, and I can see that it's actually a bit more involved that simply "forcibly use HTTP/2 regardless of any ALPN negotiation."... So... https://tools.ietf.org/html/rfc7540#section-3.4
And this... https://tools.ietf.org/html/rfc7540#section-3.5
|
Sure, what i am trying to do is send messages to several 5g core network equipments that i simulated with open source implementations such as https://github.com/open5gs/open5gs. In 5G, core network equipments are exchanging with http2 messages. They do not support http1 and most do not use TLS (some equipments are gonna use TLS in inter-network exchanges, for example in roaming scenarios). When i tried to use the http2 setting without TLS, httpcore/httpx did not take it into account since it only uses the http2 upgrade mechanism (which cannot be used in my case since 5g equipments do not answer to http1 messages) For the connection preface talked about in the RFC, it seems httpcore already uses it: For the TLS case, it seems that when trying to negociate alpn h2 with a server that does not support it, the server will just answer in http1, triggering This is an example of a message that went through with curl
|
Okay, I've had a bit of a look through their docs, but there's quite a lot to get through. What's the best resource for getting up to the point that I'd be able to run this... curl --http2-prior-knowledge -X GET "http://127.0.0.1:7777/nnrf-nfm/v1/nf-instances?nf-type=AMF&limit=10" -H "accept: application/3gppHal+json" ...against the simulated network? |
Quickest way would be to follow https://open5gs.org/open5gs/docs/guide/01-quickstart/ section 2 :
then and then you can curl the 5GC NRF equipment which is listening on 127.0.0.10:7777 with
|
What is the current status of getting http2 working in httpx ? |
We use this pull request also together with a small change in httpx to forward parameter 'http1' to httpcore. |
httpcore/_async/http2.py
Outdated
elif data.find(b"HTTP/1.1") != -1: | ||
raise RemoteProtocolError("HTTP/1.1 received") | ||
elif data.find(b"HTTP/1.0") != -1: | ||
raise RemoteProtocolError("HTTP/1.0 received") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is way too broad. For example, it could end up raising an error if the response body happened to include literal the string "HTTP/1.1" as part of the actual document content.
I think we want to remove these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in this commit
Does anybody have a live URL that we could use to test this out against? Alternatively what's the best way for us to test this? Using hypercorn perhaps? |
Looks like it... https://gitlab.com/pgjones/hypercorn/-/issues/160 |
Great stuff, @p1-alexandrevaney! I've followed up on this with some minor tweaks: #333 |
I think this works |
Feature
This PR aims to enforce the use of HTTP/2 by the AsyncHTTPClient without the need for HTTP/1 Upgrade.
Currently 5G Core network functions communicate in h2c, this httpcore feature aims to be extended in httpx to help communicating with 5GC Network Functions without TLS.
Description
When the
self.http1
attribute is set to False along with theself.http2
attribute set to True, the connection instantiated is forced toAsyncHTTP2Connection
I also added an exception in case the http2 stack receives an
HTTP/1 Bad Request
which is the answer you get when sending http2 request to a server that does not support it.For https requests, the alpn protocol
http/1.1
is removed from the ssl_context object if theself.http1
attribute is set to False along with theself.http2
attribute set to True