From 6e3205f5194f31dbc46262c0777e8b80036ed94e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 22 Sep 2012 05:53:35 +1000 Subject: [PATCH] [release-branch.go1] net/http: ignore paths on CONNECT requests in ServeMux MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« 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 »»» --- src/pkg/net/http/server.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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) } -- 2.50.0