Commit 6b17b9ba authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http2: stop rejecting outgoing paths beginning with two slashes

Updates golang/go#19103 (fixes after bundle into std)

Change-Id: I847133e289e210dedf2b89ab529478edc5de11d1
Reviewed-on: https://go-review.googlesource.com/45773
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent dfe83d41
......@@ -376,12 +376,16 @@ func (s *sorter) SortStrings(ss []string) {
// validPseudoPath reports whether v is a valid :path pseudo-header
// value. It must be either:
//
// *) a non-empty string starting with '/', but not with with "//",
// *) a non-empty string starting with '/'
// *) the string '*', for OPTIONS requests.
//
// For now this is only used a quick check for deciding when to clean
// up Opaque URLs before sending requests from the Transport.
// See golang.org/issue/16847
//
// We used to enforce that the path also didn't start with "//", but
// Google's GFE accepts such paths and Chrome sends them, so ignore
// that part of the spec. See golang.org/issue/19103.
func validPseudoPath(v string) bool {
return (len(v) > 0 && v[0] == '/' && (len(v) == 1 || v[1] != '/')) || v == "*"
return (len(v) > 0 && v[0] == '/') || v == "*"
}
......@@ -2529,7 +2529,7 @@ func TestTransportBodyDoubleEndStream(t *testing.T) {
}
}
// golangorg/issue/16847
// golang.org/issue/16847, golang.org/issue/19103
func TestTransportRequestPathPseudo(t *testing.T) {
type result struct {
path string
......@@ -2549,9 +2549,9 @@ func TestTransportRequestPathPseudo(t *testing.T) {
},
want: result{path: "/foo"},
},
// I guess we just don't let users request "//foo" as
// a path, since it's illegal to start with two
// slashes....
// In Go 1.7, we accepted paths of "//foo".
// In Go 1.8, we rejected it (issue 16847).
// In Go 1.9, we accepted it again (issue 19103).
1: {
req: &http.Request{
Method: "GET",
......@@ -2560,7 +2560,7 @@ func TestTransportRequestPathPseudo(t *testing.T) {
Path: "//foo",
},
},
want: result{err: `invalid request :path "//foo"`},
want: result{path: "//foo"},
},
// Opaque with //$Matching_Hostname/path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment