-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Supports HTTP/2 over clear TCP #722
Conversation
@@ -150,6 +150,9 @@ version. (Added in 7.33.0) | |||
.IP "--http2" | |||
(HTTP) Tells curl to issue its requests using HTTP 2. This requires that the | |||
underlying libcurl was built to support it. (Added in 7.33.0) | |||
.IP "--http2Clean" | |||
(HTTP) Tells curl to issue its requests using HTTP 2 over clean TCP without HTTP/1.1 Upgrade. This requires that the | |||
underlying libcurl was built to support it. (Added in 7.33.0) |
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.
Change 7.33 to target. I don't think this will be added until 7.49. 7.48 is a week away. Also wrap at 79
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.
Change command line option to --http2-no-upgrade
I think the name clean could be confusing. If http2clean then what is http2 someone might wonder. The "clean" version may sound better. |
--http2 --no-upgrade maybe? |
Please squash the commits so that we can easier can review/discuss the changes as done to the master branch and not as much as changes within the commit series. |
a525648
to
c410caa
Compare
.IP "--http2-no-upgrade" | ||
(HTTP) Tells curl to issue its requests using HTTP 2 over clean TCP without | ||
HTTP/1.1 Upgrade. This requires that the underlying libcurl was built to | ||
support it. (Added in 7.49.0) |
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.
So what happens if this option is set and a HTTPS URL is given? I think the docs should say...
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.
I see 2 options:
-- We can ignore this option if there is any output from ALPN ( current implementation )
-- Ignore this option on HTTPS ( not reflected by the current code )
Other idea is not to implement this option as a VERSION but as a new curl-option for the request.
And I suggest it should enable HTTP/2 for HTTPS connections too. |
45a65a4
to
11c36de
Compare
Supports HTTP/2 over clear TCP — Optimize switching to HTTP/2 by removing calls to init and setup before switching. Switching will eventually call setup and setup calls init. — Supports new version to “force” the use of HTTP/2 over clean TCP — Add common line parameter “--http2-prior-knowledge” to the Curl command line tool.
11c36de
to
fd472ed
Compare
The current implementation will enable HTTP/2 over cleartext TCP without the extra round trip of HTTP/1.1 Upgrade. It will also enable HTTP/2 over TLS if no next protocol negotiation available. |
Lovely. I still lack a bit in the docs, but I'll add some extra text there. Have you considered if we can add some code to better detect if the server actually doesn't support HTTP/2 even though prior-knowledge is used? If I try it on my http1 server I get this:
I just think it would be neat if we could detect it and say something better than "Unexpected EOF" for this case! |
About
I agree, (56) is not great. I will think about it a little more. Thanks |
If the purpose of this is forcing http2 why don't we just call it --http2-force instead of --http2-prior-knowledge |
I agree that I wouldn't say that |
@tatsuhiro-t, when we try to speak HTTP/2 with a server that is responding with HTTP/1, nghttp2_session_mem_recv() still returns a valid number that looks like it thought it was OK. Is that really intended? I tried I also tried to set an error callback, but nothing is told to that one either. Am I thinking wrong? I'm looking for ways to bring back a nicer message to curl users that they tried http2 prior knowledge to a server that clearly is not speaking HTTP/2... |
nghttp2 consumes input byte as much as possible unless there is fatal error (e.g., out of memory). Even if nghttp2_mem_recv() returns the number of all input bytes, it does not mean all bytes are correct and valid. nghttp2 might set GOAWAY to terminate connection. The error callback function (nghttp2_error_callback) introduced in the 1.9.0, is quite limited as of now. It only reports the error about incoming HTTP header fields. We can add about this case to invoke error callback in the future release. |
Thanks @tatsuhiro-t, I figured that was the situation. Do you have any recommendation on how we best detect this situation. I mean when we try to talk to HTTP/2 to a server that clearly does not understand it? The point would be to attempt to give back a better explanation to the user of why it doesn't work, nghttp2 otherwise handles the situation just fine and closes down nicely. |
We added error callback call when nghttp2 did not receive unexpected frame header while it expected initial SETTINGS frame. nghttp2/nghttp2@5974aba |
Nice, yes that helps a lot, thanks. Now I just need to make use of the error_callback properly - I've tested your new message in a test branch successfully. |
It offers extra info from nghttp2 in certain error cases. Like for example when trying prior-knowledge http2 on a server that doesn't speak http2 at all. The error message is passed on as a verbose message to libcurl. Discussed in #722 The error callback was added in nghttp2 1.9.0
With that, I think we can conclude this pull request to be "done" for now. Thanks all for your help. |
Thanks !!! |
Supports HTTP/2 over clear TCP
— Optimize switching to HTTP/2 by removing calls to init and setup
before switching. Switching will eventually call setup and setup calls
init.
— Supports new version to “force” the use of HTTP/2 over clean TCP
— Add common line parameter “—http2-no-upgrade” to the Curl command line tool.