From: Brad Fitzpatrick Date: Fri, 21 Sep 2012 19:53:35 +0000 (+1000) Subject: [release-branch.go1] net/http: ignore paths on CONNECT requests in ServeMux X-Git-Tag: go1.0.3~219 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6e3205f5194f31dbc46262c0777e8b80036ed94e;p=gostls13.git [release-branch.go1] net/http: ignore paths on CONNECT requests in ServeMux ««« backport 8eae6e390d20 net/http: ignore paths on CONNECT requests in ServeMux Fixes #3538 R=golang-dev, adg, rsc CC=golang-dev https://golang.org/cl/6117058 »»» --- diff --git a/src/pkg/net/http/server.go b/src/pkg/net/http/server.go index 0572b4ae34..ee154b65bf 100644 --- a/src/pkg/net/http/server.go +++ b/src/pkg/net/http/server.go @@ -917,11 +917,13 @@ func (mux *ServeMux) handler(r *Request) Handler { // ServeHTTP dispatches the request to the handler whose // pattern most closely matches the request URL. func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) { - // Clean path to canonical form and redirect. - if p := cleanPath(r.URL.Path); p != r.URL.Path { - w.Header().Set("Location", p) - w.WriteHeader(StatusMovedPermanently) - return + if r.Method != "CONNECT" { + // Clean path to canonical form and redirect. + if p := cleanPath(r.URL.Path); p != r.URL.Path { + w.Header().Set("Location", p) + w.WriteHeader(StatusMovedPermanently) + return + } } mux.handler(r).ServeHTTP(w, r) }