-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: get should always send go-get parameter, even after redirects #23081
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
Comments
@terinjokes thank you for filing this issue. |
@odeke-em I can confirm that for Running An aside, CL 61210 looks to be incomplete. When a handler is added for a pattern that is prefixed with a host name (as documented in http.ServeMux), the request with the trailing slash works as expected, but a request without the trailing slash gets a 404 response; the path argument to |
Quick aside: I opened #23183 for the 404 response issue mentioned above. |
I think adding ?go-get=1 to redirected URLs is a good idea. |
/cc @bcmills |
This has been going on forever, so it can persist another release. |
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
✅
What operating system and processor architecture are you using (
go env
)?What did you do?
Ran
go get -v -insecure example.org/pkg/foo
whilst "example.org" was directed to a local HTTP server (via host file).What did you expect to see?
Code downloaded from a VCS at $GOPATH/src/example.org/pkg/foo.
What did you see instead?
The behavior of the server is as follows:
Due to an issue in the server's HTTP muxer implementation1, the query parameters during the 301 redirect are lost.
go get
dutifully follows the redirect, and as the request no longer contains the "go-get" parameter, it gets and follows the redirection to godoc.org, which responds with a 500 HTTP error.This seems to be allowed behavior from the HTTP specification; the server should include the query parameters in the Location header to preserve semantics. However, I still found the behavior of
go get
surprising, both that it will sends requests without the "go-get" query parameter, and that it silently follows redirects off the import path domain.I propose change the behavior of
go get
to always include the "go-get" query parameter, even after redirects, and to log the redirections when the "-v" flag is provided.Footnotes
Fortunately, it looks like that HTTP muxer is getting fixed sometime soon CL#61210. Now that this author knows about it, he can work around it. ↩
The text was updated successfully, but these errors were encountered: