]> Cypherpunks.ru repositories - gostls13.git/commitdiff
vendor, net/http: update x/net for httplex to httpguts merge
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 7 May 2018 19:09:16 +0000 (19:09 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 7 May 2018 20:20:49 +0000 (20:20 +0000)
Updates x/net to git rev cbb82b59bc for:

    lex/httplex, http/httpguts: merge the httplex package into httpguts
    https://golang.org/cl/111875

    http2: set nextStreamID to 3 when AllowHTTP is set
    https://golang.org/cl/111835

    http2: terminate await request cancel goroutine on conn close
    https://golang.org/cl/108415

Fixes #24776 (CL 111655 didn't actually include it)

Change-Id: I0a21e169ebba2ec35219f347f1e31cd4c67bebdf
Reviewed-on: https://go-review.googlesource.com/111876
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Kunpei Sakai <namusyaka@gmail.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/go/build/deps_test.go
src/net/http/h2_bundle.go
src/net/http/http.go
src/net/http/server.go
src/net/http/transfer.go
src/net/http/transport.go
src/vendor/golang_org/x/net/http/httpguts/httplex.go [moved from src/vendor/golang_org/x/net/lex/httplex/httplex.go with 97% similarity]
src/vendor/golang_org/x/net/http/httpguts/httplex_test.go [moved from src/vendor/golang_org/x/net/lex/httplex/httplex_test.go with 99% similarity]

index 71ea97280b7f607160a33bde0fceff323f33a98a..451c2e0a4c262615ff142832424c9fa67ecbec0e 100644 (file)
@@ -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",
index 12473dc742344122a659c60440947c0b9291a566..f0dd8e6c761a1c1b6d7c5b872020947ec67c908b 100644 (file)
@@ -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
index b95ca89f4094c5f04445c83ad5c3d9069cc777f9..ce0eceb1de303b67602f32235f756f011d21cc2a 100644 (file)
@@ -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 {
index be28a252c8cbfb3f0510d6f4794bac97df247f94..ac5cadd8d0a5419f09af7c760fb3401f1566627b 100644 (file)
@@ -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")
                        }
                }
index e0fafb2a6dda51e6e6bc2582d1e434b5c9666899..632c58249ad0fb5db54c70e387025227323d1680 100644 (file)
@@ -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 {
index b19f7ce8ed0178c48f0cd62b5f6ccabb64a4adf3..cce88ca239ac23369c59bee42de9cca2ee479c49 100644 (file)
@@ -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)
                                }
                        }
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 b6493f045a2202d49cf800e6af6904857777a84e..9337435174e677336726aa5f81160bd2ef4fb7fb 100644 (file)
@@ -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"
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 f47adc939fece61d8647a214fd3be5025c912a0c..a2c57f3927eab1c5cffbbfae598d334b91a1ea0e 100644 (file)
@@ -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"