1
0
mirror of https://github.com/golang/go synced 2024-11-25 09:07:58 -07:00

net/http: ignore paths on CONNECT requests in ServeMux

Fixes #3538

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/6117058
This commit is contained in:
Brad Fitzpatrick 2012-04-25 12:46:16 -07:00
parent 7f7a70f225
commit 61a8eb07f8

View 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)
}