Skip to content

Commit 003dbc4

Browse files
committed
net/http: roll back "clean the path of the stripped URL by StripPrefix"
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 <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 27eaffc commit 003dbc4

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

src/net/http/serve_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,15 +2900,6 @@ func TestStripPrefix(t *testing.T) {
29002900
t.Errorf("test 2: got status %v, want %v", g, e)
29012901
}
29022902
res.Body.Close()
2903-
2904-
res, err = c.Get(ts.URL + "/foo")
2905-
if err != nil {
2906-
t.Fatal(err)
2907-
}
2908-
if g, e := res.Header.Get("X-Path"), "/"; g != e {
2909-
t.Errorf("test 3: got %s, want %s", g, e)
2910-
}
2911-
res.Body.Close()
29122903
}
29132904

29142905
// https://golang.org/issue/18952.

src/net/http/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ func StripPrefix(prefix string, h Handler) Handler {
20422042
*r2 = *r
20432043
r2.URL = new(url.URL)
20442044
*r2.URL = *r.URL
2045-
r2.URL.Path = cleanPath(p)
2045+
r2.URL.Path = p
20462046
h.ServeHTTP(w, r2)
20472047
} else {
20482048
NotFound(w, r)

0 commit comments

Comments
 (0)