]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: roll back "clean the path of the stripped URL by StripPrefix"
authorDmitri Shuralyov <dmitshur@golang.org>
Tue, 4 Jun 2019 21:21:33 +0000 (21:21 +0000)
committerDmitri Shuralyov <dmitshur@golang.org>
Tue, 4 Jun 2019 22:36:51 +0000 (22:36 +0000)
Roll back CL 161738. That fix changed StripPrefix behavior in the
general case, not just in the situation where where stripping the
prefix from path resulted in the empty string, causing issue #31622.

That kind of change to StripPrefix behavior is not backwards compatible,
and there can be a smaller, more targeted fix for the original issue.

Fixes #31622
Updates #30165

Change-Id: Ie2fcfe6787a32e44f71d564d8f9c9d580fc6f704
Reviewed-on: https://go-review.googlesource.com/c/go/+/180498
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/serve_test.go
src/net/http/server.go

index 1c67b40161ce7f064375b6e5154bfc057628a341..679936e115270125f7059ac6785cb09b9b0d2e7e 100644 (file)
@@ -2900,15 +2900,6 @@ func TestStripPrefix(t *testing.T) {
                t.Errorf("test 2: got status %v, want %v", g, e)
        }
        res.Body.Close()
-
-       res, err = c.Get(ts.URL + "/foo")
-       if err != nil {
-               t.Fatal(err)
-       }
-       if g, e := res.Header.Get("X-Path"), "/"; g != e {
-               t.Errorf("test 3: got %s, want %s", g, e)
-       }
-       res.Body.Close()
 }
 
 // https://golang.org/issue/18952.
index 30bc9680f47b789aa98b236098d668cca7aa0aa2..82145ebd659a93dceb6e819d2d30d018cb7570e0 100644 (file)
@@ -2042,7 +2042,7 @@ func StripPrefix(prefix string, h Handler) Handler {
                        *r2 = *r
                        r2.URL = new(url.URL)
                        *r2.URL = *r.URL
-                       r2.URL.Path = cleanPath(p)
+                       r2.URL.Path = p
                        h.ServeHTTP(w, r2)
                } else {
                        NotFound(w, r)