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

net/http: doFollowingRedirects changes URL on redirect #8292

Closed
mattdr opened this issue Jun 27, 2014 · 2 comments
Closed

net/http: doFollowingRedirects changes URL on redirect #8292

mattdr opened this issue Jun 27, 2014 · 2 comments
Milestone

Comments

@mattdr
Copy link

mattdr commented Jun 27, 2014

When following a redirect (e.g. 302), doFollowingRedirects will call URL.Parse() on the
value of the Location header, then use URL.String() from the resulting object as the new
URL. URL.String(URL.Parse(x)) doesn't round-trip. In particular, %2F gets flattened to
"/" but never converted back. This caveat is noted here:
http://golang.org/pkg/net/url/#URL.

As a result, a server can't actually redirect a Go client to a URL with %2F in it. This
disagrees with the behavior of at least Chrome and curl.

I expect the best option here is to make URL.Parse / URL.String round-trip, since the
%2F exception is weird and surprising. At the very least, net/http should keep the
verbatim URL when redirecting.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-none.

@mattdr
Copy link
Author

mattdr commented Nov 17, 2014

Comment 2:

Comments on this page suggest that developers trying to use Go to consume Google Cloud
APIs using Google-provided libraries are hitting similar problems with '/' not
round-tripping.
https://code.google.com/p/google-api-go-client/wiki/GettingStarted

@bradfitz bradfitz removed the new label Dec 18, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc closed this as completed in 874a605 Jun 22, 2015
@mikioh mikioh modified the milestones: Go1.5, Unplanned Jun 22, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

6 participants