Skip to content
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

x/net/http2: handle CONNECT request #15336

Closed
lysu opened this issue Apr 16, 2016 · 2 comments
Closed

x/net/http2: handle CONNECT request #15336

lysu opened this issue Apr 16, 2016 · 2 comments

Comments

@lysu
Copy link

lysu commented Apr 16, 2016

As h2 spec : http://httpwg.org/specs/rfc7231.html#CONNECT

when we receive a CONNECT request, we should open a tcp connection to the target server identified in the :authority..and response to sender an 2XX, then pipe client connection and target server connection..

But in current h2: we can't response sender with and only with 2xx code, WriteHeader(code int) alway take content-length and other headers in and it causes some problems( http://httpwg.org/specs/rfc7231.html#CONNECT) and let client don't send any more data

Except that, h2-server always send 2xx and some headers to client after http.Handler finish its execution..and how can we forbidden this? because in 'proxy' situation, data will be exchanged between client and proxied server, proxy should not generate a 'response' by itself...(except previous response 2xx code to client)

Is there a recommend way to send client only one HeaderFrame with :status: 200 and forbidden 'after handle done response(just like http1.x w.conn.hijacked())'?

@bradfitz
Copy link
Contributor

You linked to the HTTP/1.1 spec (RFC 7231). The HTTP/2 spec's rules regarding CONNECT are in: http://httpwg.org/specs/rfc7540.html#CONNECT

You can use http.Flusher to write out a 200 response, and then you can bidirectional stream the request body and write the response body (with Flusher again).

This is a dup of #13717. In particular, see the comment #13444 (comment) that's linked from there.

@lysu
Copy link
Author

lysu commented Apr 20, 2016

Oh~ with http.Flusher, it works!!!..
It seems very magic, and I need read more source code about it...
thanks bradfitz ^ ^

@golang golang locked and limited conversation to collaborators Apr 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants