diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index 71ea97280b..451c2e0a4c 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -404,7 +404,6 @@ var pkgDeps = map[string][]string{ "golang_org/x/net/http/httpguts", "golang_org/x/net/http2/hpack", "golang_org/x/net/idna", - "golang_org/x/net/lex/httplex", "golang_org/x/text/unicode/norm", "golang_org/x/text/width", "internal/nettrace", diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 12473dc742..f0dd8e6c76 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -47,7 +47,6 @@ import ( "golang_org/x/net/http/httpguts" "golang_org/x/net/http2/hpack" "golang_org/x/net/idna" - "golang_org/x/net/lex/httplex" ) // A list of the possible cipher suite ids. Taken from @@ -2746,7 +2745,7 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFr if http2VerboseLogs && fr.logReads { fr.debugReadLoggerf("http2: decoded hpack field %+v", hf) } - if !httplex.ValidHeaderFieldValue(hf.Value) { + if !httpguts.ValidHeaderFieldValue(hf.Value) { invalid = http2headerFieldValueError(hf.Value) } isPseudo := strings.HasPrefix(hf.Name, ":") @@ -3372,7 +3371,7 @@ var ( ) // validWireHeaderFieldName reports whether v is a valid header field -// name (key). See httplex.ValidHeaderName for the base rules. +// name (key). See httpguts.ValidHeaderName for the base rules. // // Further, http2 says: // "Just as in HTTP/1.x, header field names are strings of ASCII @@ -3384,7 +3383,7 @@ func http2validWireHeaderFieldName(v string) bool { return false } for _, r := range v { - if !httplex.IsTokenRune(r) { + if !httpguts.IsTokenRune(r) { return false } if 'A' <= r && r <= 'Z' { @@ -6846,7 +6845,9 @@ func (http2noCachedConnError) Error() string { return "http2: no cached connecti // or its equivalent renamed type in net/http2's h2_bundle.go. Both types // may coexist in the same running program. func http2isNoCachedConnError(err error) bool { - _, ok := err.(interface{ IsHTTP2NoCachedConnError() }) + _, ok := err.(interface { + IsHTTP2NoCachedConnError() + }) return ok } @@ -7092,6 +7093,10 @@ func (t *http2Transport) newClientConn(c net.Conn, singleUse bool) (*http2Client // henc in response to SETTINGS frames? cc.henc = hpack.NewEncoder(&cc.hbuf) + if t.AllowHTTP { + cc.nextStreamID = 3 + } + if cs, ok := c.(http2connectionStater); ok { state := cs.ConnectionState() cc.tlsState = &state @@ -7476,6 +7481,9 @@ func (cc *http2ClientConn) awaitOpenSlotForRequest(req *Request) error { for { cc.lastActive = time.Now() if cc.closed || !cc.canTakeNewRequestLocked() { + if waitingForConn != nil { + close(waitingForConn) + } return http2errClientConnUnusable } if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) { @@ -7699,7 +7707,7 @@ func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trail if host == "" { host = req.URL.Host } - host, err := httplex.PunycodeHostPort(host) + host, err := httpguts.PunycodeHostPort(host) if err != nil { return nil, err } @@ -7724,11 +7732,11 @@ func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trail // potentially pollute our hpack state. (We want to be able to // continue to reuse the hpack encoder for future requests) for k, vv := range req.Header { - if !httplex.ValidHeaderFieldName(k) { + if !httpguts.ValidHeaderFieldName(k) { return nil, fmt.Errorf("invalid HTTP header name %q", k) } for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { + if !httpguts.ValidHeaderFieldValue(v) { return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k) } } @@ -8769,7 +8777,7 @@ func (t *http2Transport) getBodyWriterState(cs *http2clientStream, body io.Reade } s.delay = t.expectContinueTimeout() if s.delay == 0 || - !httplex.HeaderValuesContainsToken( + !httpguts.HeaderValuesContainsToken( cs.req.Header["Expect"], "100-continue") { return @@ -8824,7 +8832,7 @@ func (s http2bodyWriterState) scheduleBodyWrite() { // isConnectionCloseRequest reports whether req should use its own // connection for a single request and then close the connection. func http2isConnectionCloseRequest(req *Request) bool { - return req.Close || httplex.HeaderValuesContainsToken(req.Header["Connection"], "close") + return req.Close || httpguts.HeaderValuesContainsToken(req.Header["Connection"], "close") } // writeFramer is implemented by any type that is used to write frames. @@ -9164,7 +9172,7 @@ func http2encodeHeaders(enc *hpack.Encoder, h Header, keys []string) { } isTE := k == "transfer-encoding" for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { + if !httpguts.ValidHeaderFieldValue(v) { // TODO: return an error? golang.org/issue/14048 // For now just omit it. continue diff --git a/src/net/http/http.go b/src/net/http/http.go index b95ca89f40..ce0eceb1de 100644 --- a/src/net/http/http.go +++ b/src/net/http/http.go @@ -11,7 +11,7 @@ import ( "time" "unicode/utf8" - "golang_org/x/net/lex/httplex" + "golang_org/x/net/http/httpguts" ) // maxInt64 is the effective "infinite" value for the Server and @@ -47,7 +47,7 @@ func removeEmptyPort(host string) string { } func isNotToken(r rune) bool { - return !httplex.IsTokenRune(r) + return !httpguts.IsTokenRune(r) } func isASCII(s string) bool { diff --git a/src/net/http/server.go b/src/net/http/server.go index be28a252c8..ac5cadd8d0 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -29,7 +29,6 @@ import ( "time" "golang_org/x/net/http/httpguts" - "golang_org/x/net/lex/httplex" ) // Errors used by the HTTP server. @@ -964,15 +963,15 @@ func (c *conn) readRequest(ctx context.Context) (w *response, err error) { if len(hosts) > 1 { return nil, badRequestError("too many Host headers") } - if len(hosts) == 1 && !httplex.ValidHostHeader(hosts[0]) { + if len(hosts) == 1 && !httpguts.ValidHostHeader(hosts[0]) { return nil, badRequestError("malformed Host header") } for k, vv := range req.Header { - if !httplex.ValidHeaderFieldName(k) { + if !httpguts.ValidHeaderFieldName(k) { return nil, badRequestError("invalid header name") } for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { + if !httpguts.ValidHeaderFieldValue(v) { return nil, badRequestError("invalid header value") } } diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go index e0fafb2a6d..632c58249a 100644 --- a/src/net/http/transfer.go +++ b/src/net/http/transfer.go @@ -19,7 +19,7 @@ import ( "sync" "time" - "golang_org/x/net/lex/httplex" + "golang_org/x/net/http/httpguts" ) // ErrLineTooLong is returned when reading request or response bodies @@ -690,9 +690,9 @@ func shouldClose(major, minor int, header Header, removeCloseHeader bool) bool { } conv := header["Connection"] - hasClose := httplex.HeaderValuesContainsToken(conv, "close") + hasClose := httpguts.HeaderValuesContainsToken(conv, "close") if major == 1 && minor == 0 { - return hasClose || !httplex.HeaderValuesContainsToken(conv, "keep-alive") + return hasClose || !httpguts.HeaderValuesContainsToken(conv, "keep-alive") } if hasClose && removeCloseHeader { diff --git a/src/net/http/transport.go b/src/net/http/transport.go index b19f7ce8ed..cce88ca239 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -28,7 +28,7 @@ import ( "sync/atomic" "time" - "golang_org/x/net/lex/httplex" + "golang_org/x/net/http/httpguts" ) // DefaultTransport is the default implementation of Transport and is @@ -363,11 +363,11 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { isHTTP := scheme == "http" || scheme == "https" if isHTTP { for k, vv := range req.Header { - if !httplex.ValidHeaderFieldName(k) { + if !httpguts.ValidHeaderFieldName(k) { return nil, fmt.Errorf("net/http: invalid header field name %q", k) } for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { + if !httpguts.ValidHeaderFieldValue(v) { return nil, fmt.Errorf("net/http: invalid header field value %q for key %v", v, k) } } diff --git a/src/vendor/golang_org/x/net/lex/httplex/httplex.go b/src/vendor/golang_org/x/net/http/httpguts/httplex.go similarity index 97% rename from src/vendor/golang_org/x/net/lex/httplex/httplex.go rename to src/vendor/golang_org/x/net/http/httpguts/httplex.go index b6493f045a..9337435174 100644 --- a/src/vendor/golang_org/x/net/lex/httplex/httplex.go +++ b/src/vendor/golang_org/x/net/http/httpguts/httplex.go @@ -2,12 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package httplex contains rules around lexical matters of various -// HTTP-related specifications. -// -// This package is shared by the standard library (which vendors it) -// and x/net/http2. It comes with no API stability promise. -package httplex +package httpguts import ( "net" diff --git a/src/vendor/golang_org/x/net/lex/httplex/httplex_test.go b/src/vendor/golang_org/x/net/http/httpguts/httplex_test.go similarity index 99% rename from src/vendor/golang_org/x/net/lex/httplex/httplex_test.go rename to src/vendor/golang_org/x/net/http/httpguts/httplex_test.go index f47adc939f..a2c57f3927 100644 --- a/src/vendor/golang_org/x/net/lex/httplex/httplex_test.go +++ b/src/vendor/golang_org/x/net/http/httpguts/httplex_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package httplex +package httpguts import ( "testing"