]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] net/http: ignore paths on CONNECT requests in ServeMux
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 21 Sep 2012 19:53:35 +0000 (05:53 +1000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 21 Sep 2012 19:53:35 +0000 (05:53 +1000)
««« 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

index 0572b4ae3477466a16a2742128af7fc9f4c6abe4..ee154b65bfb60509506e2ec6c455fba0949aed31 100644 (file)
@@ -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)
 }