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

Fix HTTP tunnel #2448

Merged
merged 5 commits into from
May 1, 2023
Merged

Fix HTTP tunnel #2448

merged 5 commits into from
May 1, 2023

Conversation

flobernd
Copy link
Contributor

According to https://datatracker.ietf.org/doc/html/draft-luotonen-web-proxy-tunneling-01#section-3.2, the expected response to a CONNECT should be HTTP/1.1 200 Connection established instead of HTTP/1.1 200 OK. Allow both responses for now (as still a lot of proxy implementations fail to follow the standard).

A HTTP(S), SOCKS, etc. proxy is traditionally specified by an URI of form scheme://[user:pass@]host[:port]. Accept both formats for backwards compatibility.

According to https://datatracker.ietf.org/doc/html/draft-luotonen-web-proxy-tunneling-01#section-3.2, the expected response to a `CONNECT` should be `HTTP/1.1 200 Connection established` instead of `HTTP/1.1 200 OK`. Allow both responses for now (as still a lot of proxy implementations fail to follow the standard).
A HTTP(S), SOCKS, etc. proxy is traditionally specified by an URI of form `scheme://[user:pass@]host[:port]`. Accept both formats for backwards compatibility.
@mgravell
Copy link
Collaborator

LGTM

Copy link
Collaborator

@mgravell mgravell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional change looks good; parsing change: IMO needs tests

{
value = value.Substring(5);
if (!Format.TryParseEndPoint(value, out var ep))
// For backwards compatibility with `http:address_with_port`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should add tests for this change, i.e. that we get the expected values back out - even if that means poking at internal state after the parse

Copy link
Contributor Author

@flobernd flobernd Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the new format to the roundtrip test. This should be sufficient to confirm that the resulting Tunnel is the same for both input formats (HttpProxyTunnel.ToString() internally uses this.EndPoint.ToString() which means address and port must be the same to end up with the same string).

IMO it would make sense to consider deprecating the old format for the following reasons:

  • Roundtrip is inconsistent now, if you use the URI format
  • URI format is standard
  • URI format supports authentication (username + password) if needed at some point of time

Edit: If you prefer, we can apply the parsing change in a different PR (or remove it at all - it's up to you).
Edit 2: Not sure why the unrelated test fails after my latest commit. Seems a random failure, maybe you can re-run the CI.

@flobernd flobernd requested a review from mgravell April 27, 2023 07:16
@flobernd
Copy link
Contributor Author

flobernd commented Apr 27, 2023

Seems like the CI is broken 👀 third run failed as well.

@NickCraver NickCraver merged commit 9f3f76d into StackExchange:main May 1, 2023
@NickCraver
Copy link
Collaborator

@flobernd updated release notes and landed on - thank you!!

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