-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: ServeMux redirect loses query info #17841
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
In summary:
I assume your question is about my third case? ( But you said What is your actual bug report? |
correct, I edited the issue to reflect the typo. The error is in case #3 where a re-direct occurs and doesn't forward the query string. Thanks for looking at this. |
Not a regression from Go 1.7, so targetting Go 1.9. |
And here is a playground runnable repro https://play.golang.org/p/t0sLqU5tIS for anyone who wants to test or fix the bug. |
CL https://golang.org/cl/43779 mentions this issue. |
I've mailed https://go-review.googlesource.com/43779. |
@odeke-em, nice find! Yeah, if you could send them a PR to make their test work with either Go 1.8 or Go 1.9, that'd save everybody a lot of hassle later. Thanks! |
Aye aye, done sent in kubernetes/kubernetes#46306. |
Fixes kubernetes#46282. After golang/go#17841 was fixed as part of Go1.9, Go's http.ServeMux now forwards along the query string during redirects. The tests pre-Go1.9 relied on the old/buggy behavior. This PR ensures both forward and backward compability so that if the new redirect Location is received with either pre-Go1.9 behavior or Go1.9+ behavior, we can still properly test for both.
From offline discussions with @bradfitz, the closing CL broke the builds at tip and didn't account for the case where Redirect was invoked directly with a full URL that itself had its own query string. Reopening this issue. |
CL https://golang.org/cl/44100 mentions this issue. |
CL 43779/commit 6a6c792 broke the builds at tip, and that CL doesn't account for cases where Redirect is directly invoked with a full URL that itself has a query string. Updates #17841 Change-Id: Idb0486bae8625e1f9e033ca4cfcd87de95bc835c Reviewed-on: https://go-review.googlesource.com/44100 Reviewed-by: Brad Fitzpatrick <[email protected]>
We should only change |
Change https://golang.org/cl/61210 mentions this issue: |
@odeke-em Could you take a look at the CL? |
Thank you for the ping @namusyaka, and thank you for the CL, I am going to take a look at it in a few. |
@sdwarwick The issue has been fixed by this commit. Please let me know if you still have the issue. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.1 windows/amd64
What operating system and processor architecture are you using (
go env
)?go version go1.7.1 windows/amd64
What did you do?
this error cannot be seen on play as it requires http.
What did you expect to see?
This version works:
input URL: http://localhost:8008/testOne?this=that
result: URL stays the same, and the output is: map[this:[that]]
This doesn't:
input URL: http://localhost:8008/testTwo?this=that
result: URL is redirected to http://localhost:8008/testTwo/
there is no output.
conclusion:
query strings are lost when the input URL and the http router have a "/" at the end of the selector.
this error was initially reported in #5382,
I hope that this is sufficient information.
The text was updated successfully, but these errors were encountered: