-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net/http: cannot set custom/special pseudo-headers when using HTTP/2 #32763
Comments
Also, a link to what I have currently of the client side of the HTTP/2 handshake: https://github.com/niaow/exp/blob/1ed5641ad76ca5761af3a652406bf49b7cac2ce3/ws/handshake.go#L248 |
This is somewhat related to #27244 |
@bradfitz how about we automatically convert HTTP/1.1 Upgrade requests into HTTP/2 if the peer supports it in *http.Transport? We'd have to perform an initial HTTP/2 request on the endpoint to check if it supports RFC 8441, cache that and then from there we can automatically decide whether or not to do HTTP/1.1 or HTTP/2 for subsequent upgrades. Would mean my WebSocket library basically gets client side HTTP/2 WebSockets for free and httputil.ReverseProxy can proxy RFC 8441 connect requests. |
For the server side
|
There was previous discussion of this at #26937 (comment). |
@jadr2ddude, thank you for filing this issue! As @nhooyr mentioned, so if you are implementing Websockets I believe the first step that you want to do is to hijack the connection and then if you know you are using HTTP/2, you can use the golang.org/x/net/http2 package to create the framer and send over the respective headers by yourself. IMHO we shouldn't be changing net/http to make that change here. Please feel free to reopen though if I've missed something, thank you! |
@odeke-em how would you use the framer without having to rewrite or fork most of net/http? This needs both client and server support. |
You can’t hijack the connection with http/2. So this needs to be reopened. |
My apologies @jadr2ddude @mikedanese @nhooyr for the brainless close and non-responsiveness for the correction, I posted my response right before a long dinner. Thanks for reopening it, Brad! |
@bradfitz I'd like to prepare some CLs for this in the coming weeks, could you please review my proposal above? |
With @bradfitz leaving Google, who is going to be maintaining net/http? Who do I have to convince re my proposal? @andybons |
@fraenkel have any thoughts about this? |
Currently I see a couple of outstanding issues. Some we can fix, one I am not so sure about. The part I don't see how to handle is hijacking the http2 stream on the client side. Things should work correctly on the server side using the request.Body and ResponseWriter. |
See my proposal #32763 (comment) There's already an existing API to hijack HTTP/1.1 streams so we should be able to reuse it for HTTP/2. |
Changing the meaning of |
Are there some plans to add the support in the next time? We are trying to enable http/2 at our cloud foundry environment and noticed that the gorouter cannot handle http/2 websockets. I also opend issue cloudfoundry/routing-release#230. Chrome as a client is also supporting it in the meantime https://www.chromestatus.com/feature/6251293127475200 this would lead into connection problems. |
Duplicate of #49918 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I attempted to implement websockets over HTTP/2, AKA RFC 8441, with
net/http
.What did you expect to see?
Some mechanism of setting
:protocol
as defined in section 5 of RFC 8441.What did you see instead?
There is no way to specify extra pseudo-headers in a request with
net/http
, at least that I can find in the header encoding code.I am really not sure what the best way to solve this would be, or whether it is fully worthwhile. However, I would really like to be able to use a user-provided
*http.Client
for this, and this is the only thing I have not yet found a workaround for.Clarification: pseudo-headers do not satisfy
httpguts.ValidHeaderFieldName
and therefore cannot be passed in with the regular headersThe text was updated successfully, but these errors were encountered: