Commit 8e9386db authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

vendor, net/http: update x/net for httplex to httpguts merge

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: 's avatarKunpei Sakai <namusyaka@gmail.com>
Reviewed-by: 's avatarAndrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 9b16b9c7
......@@ -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",
......
......@@ -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
......
......@@ -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 {
......
......@@ -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")
}
}
......
......@@ -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 {
......
......@@ -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)
}
}
......
......@@ -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"
......
......@@ -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"
......
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