Skip to content

Commit 802cb59

Browse files
committed
net/http: update bundled x/net/http2
Updates x/net/http2 (and x/net/lex/httplex) to git rev 749a502 for: http2: don't sniff first Request.Body byte in Transport until we have a conn https://golang.org/cl/29074 Fixes #17071 http2: add Transport support for unicode domain names https://golang.org/cl/29071 Updates #13835 http2: don't send bogus :path pseudo headers if Request.URL.Opaque is set https://golang.org/cl/27632 + http2: fix bug where '*' as a valid :path value in Transport https://golang.org/cl/29070 Updates #16847 http2: fix all vet warnings https://golang.org/cl/28344 Updates #16228 Updates #11041 Also uses the new -underscore flag to x/tools/cmd/bundle from https://golang.org/cl/29086 Change-Id: Ica0f6bf6e33266237e37527a166a783d78c059c4 Reviewed-on: https://go-review.googlesource.com/29110 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Chris Broadfoot <[email protected]>
1 parent 9980b70 commit 802cb59

File tree

4 files changed

+110
-12
lines changed

4 files changed

+110
-12
lines changed

src/go/build/deps_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ var pkgDeps = map[string][]string{
379379
"mime/multipart", "runtime/debug",
380380
"net/http/internal",
381381
"golang_org/x/net/http2/hpack",
382+
"golang_org/x/net/idna",
382383
"golang_org/x/net/lex/httplex",
383384
"internal/nettrace",
384385
"net/http/httptrace",

src/net/http/h2_bundle.go

+52-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vendor/golang_org/x/net/lex/httplex/httplex.go

+39
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
package httplex
1111

1212
import (
13+
"net"
1314
"strings"
1415
"unicode/utf8"
16+
17+
"golang_org/x/net/idna"
1518
)
1619

1720
var isTokenTable = [127]bool{
@@ -310,3 +313,39 @@ func ValidHeaderFieldValue(v string) bool {
310313
}
311314
return true
312315
}
316+
317+
func isASCII(s string) bool {
318+
for i := 0; i < len(s); i++ {
319+
if s[i] >= utf8.RuneSelf {
320+
return false
321+
}
322+
}
323+
return true
324+
}
325+
326+
// PunycodeHostPort returns the IDNA Punycode version
327+
// of the provided "host" or "host:port" string.
328+
func PunycodeHostPort(v string) (string, error) {
329+
if isASCII(v) {
330+
return v, nil
331+
}
332+
333+
host, port, err := net.SplitHostPort(v)
334+
if err != nil {
335+
// The input 'v' argument was just a "host" argument,
336+
// without a port. This error should not be returned
337+
// to the caller.
338+
host = v
339+
port = ""
340+
}
341+
host, err = idna.ToASCII(host)
342+
if err != nil {
343+
// Non-UTF-8? Not representable in Punycode, in any
344+
// case.
345+
return "", err
346+
}
347+
if port == "" {
348+
return host, nil
349+
}
350+
return net.JoinHostPort(host, port), nil
351+
}

src/vendor/golang_org/x/net/lex/httplex/httplex_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,21 @@ func TestHeaderValuesContainsToken(t *testing.T) {
9999
}
100100
}
101101
}
102+
103+
func TestPunycodeHostPort(t *testing.T) {
104+
tests := []struct {
105+
in, want string
106+
}{
107+
{"www.google.com", "www.google.com"},
108+
{"гофер.рф", "xn--c1ae0ajs.xn--p1ai"},
109+
{"bücher.de", "xn--bcher-kva.de"},
110+
{"bücher.de:8080", "xn--bcher-kva.de:8080"},
111+
{"[1::6]:8080", "[1::6]:8080"},
112+
}
113+
for _, tt := range tests {
114+
got, err := PunycodeHostPort(tt.in)
115+
if tt.want != got || err != nil {
116+
t.Errorf("PunycodeHostPort(%q) = %q, %v, want %q, nil", tt.in, got, err, tt.want)
117+
}
118+
}
119+
}

0 commit comments

Comments
 (0)