Skip to content

net/http ServeMux clears query when redirecting #18249

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

Closed
Maydell opened this issue Dec 8, 2016 · 1 comment
Closed

net/http ServeMux clears query when redirecting #18249

Maydell opened this issue Dec 8, 2016 · 1 comment

Comments

@Maydell
Copy link

Maydell commented Dec 8, 2016

What version of Go are you using (go version)?

What operating system and processor architecture are you using (go env)?

go version go1.7.1 linux/amd64

What did you do?

package main

import "net/http"

func main() {
	http.HandleFunc("/route/", func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(http.StatusInternalServerError)
	})

	http.ListenAndServe(":8080", nil)
}

I made a request to the above server as follows
curl "localhost:8080/route?test=a" -v

What did you expect to see?

As described in the docs, I expected the server to redirect me to path /route/?test=a

What did you see instead?

Instead the server redirected me to path /route/, ignoring the query provided in the original request.

*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /route?test=a HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location: /route/
< Date: Thu, 08 Dec 2016 18:22:54 GMT
< Content-Length: 42
< Content-Type: text/html; charset=utf-8
< 
<a href="/route/">Moved Permanently</a>.

* Connection #0 to host localhost left intact
@bradfitz
Copy link
Contributor

bradfitz commented Dec 8, 2016

Dup of #17841

@bradfitz bradfitz closed this as completed Dec 8, 2016
@golang golang locked and limited conversation to collaborators Dec 8, 2017
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

3 participants