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

Backwards incompatible! HostClient can't switch between protocols #800

Merged
merged 1 commit into from
May 18, 2020

Conversation

erikdubbelboer
Copy link
Collaborator

HostClient connects to its host though either HTTP or HTTPS. It should never switch between protocols. This breaks the HostClient maps inside Client. There are two maps there:
m is for http HostClients
ms is for https HostClients
Updating a http HostClient to https, while it is still inside map m will make all future requests to the given http host go to https. Since servers can serve different content on both ports this can break things.

Thats why from now on HostClient will throw and error when it is used outside Client and tries to follow a redirect to a different protocol.

erikdubbelboer referenced this pull request May 2, 2020
Copy link
Owner

@valyala valyala left a comment

Choose a reason for hiding this comment

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

Looks good overall

@@ -46,11 +46,10 @@ type Request struct {

keepBodyBuffer bool

// Used by Server to indicate the request was received on a HTTPS endpoint.
// Client/HostClient shouldn't use this field but should depend on the uri.scheme instead.
isTLS bool
Copy link
Owner

Choose a reason for hiding this comment

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

Do we really need for this field now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I also wanted to remove it, but the messy way URIs are handled prevents this. This needs to be set from Server so that the URI.parse call happening at some point can know if the server was http or https. We can't just set Request.uri.scheme instead because a Request from a Server doesn't use the parsed uri but instead has this other form which then later gets parsed. Its all super messy but I don't see how I can improve that all without breaking the URI/``Request APIs.

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.

2 participants