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

Don't return http 200 for ConnectHijack actions #377

Merged
merged 1 commit into from
Apr 21, 2020

Conversation

riraccuia
Copy link
Contributor

@riraccuia riraccuia commented Mar 28, 2020

#376
Sending HTTP 200 to the client connection before invoking the todo.Hijack() method for a ConnectHijack action makes it impossible to cascade the http 502 (or any other error) back to the client in case we wanted to abort prematurely (e.g. the target address is unavailable)

RFC 2817 States:

5.3 Establishing a Tunnel with CONNECT

   Any successful (2xx) response to a CONNECT request indicates that the
   proxy has established a connection to the requested host and port,
   and has switched to tunneling the current connection to that server
   connection.

It should be therefore up to the Hijack() method implementer to send the http 200 upon confirming that we can establish a tunnel.

Sending HTTP 200 back to the client connection before invoking the todo.Hijack() method for a ConnectHijack action makes it impossible to cascade the http 502 back to the client in case we wanted to abort prematurely (e.g.the target address is unavailable)

[RFC 2817](https://tools.ietf.org/html/rfc2817#section-5.3) States: 

```
5.3 Establishing a Tunnel with CONNECT

   Any successful (2xx) response to a CONNECT request indicates that the
   proxy has established a connection to the requested host and port,
   and has switched to tunneling the current connection to that server
   connection.
```

It should be therefore up to the Hijack() method implementer to send the http 200 upon confirming that we can establish a tunnel.
@dmagyar
Copy link

dmagyar commented Apr 17, 2020

I would like to second this PR, we had to maintain a local fork so we can hijack 200 messages on CONNECTs. Thanks for raising this @riraccuia!

@elazarl elazarl merged commit e76ad31 into elazarl:master Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants