Commit 61a8eb07 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: ignore paths on CONNECT requests in ServeMux

Fixes #3538

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/6117058
parent 7f7a70f2
...@@ -917,11 +917,13 @@ func (mux *ServeMux) handler(r *Request) Handler { ...@@ -917,11 +917,13 @@ func (mux *ServeMux) handler(r *Request) Handler {
// ServeHTTP dispatches the request to the handler whose // ServeHTTP dispatches the request to the handler whose
// pattern most closely matches the request URL. // pattern most closely matches the request URL.
func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) { func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) {
// Clean path to canonical form and redirect. if r.Method != "CONNECT" {
if p := cleanPath(r.URL.Path); p != r.URL.Path { // Clean path to canonical form and redirect.
w.Header().Set("Location", p) if p := cleanPath(r.URL.Path); p != r.URL.Path {
w.WriteHeader(StatusMovedPermanently) w.Header().Set("Location", p)
return w.WriteHeader(StatusMovedPermanently)
return
}
} }
mux.handler(r).ServeHTTP(w, r) mux.handler(r).ServeHTTP(w, r)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment