diff options
| author | Jorropo <jorropo.pgm@gmail.com> | 2022-04-30 10:52:13 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-05-02 04:45:15 +0000 |
| commit | d8723745bacd1960139ea866e61377a0a75aec2f (patch) | |
| tree | 73bd5787850d94d647fdc74b1a5c23fc723731e6 /src/net/http | |
| parent | d09ca2cb8ec5306f20b527266ce161bd9292cad4 (diff) | |
| download | go-d8723745bacd1960139ea866e61377a0a75aec2f.tar.xz | |
vendor, net/http: update golang.org/x/net to tip
Needed for CL 400236.
Change-Id: Ia0b4a5963724ed92be27f557ad141335b389e97f
GitHub-Last-Rev: b0e72cb26de251865ef865bf92a6b8ff9dbf7b04
GitHub-Pull-Request: golang/go#52621
Reviewed-on: https://go-review.googlesource.com/c/go/+/403136
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/net/http')
| -rw-r--r-- | src/net/http/h2_bundle.go | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 4a76e6afe8..2f3eb9c573 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -30,7 +30,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "math" mathrand "math/rand" @@ -1294,7 +1293,7 @@ func (e http2headerFieldNameError) Error() string { type http2headerFieldValueError string func (e http2headerFieldValueError) Error() string { - return fmt.Sprintf("invalid header field value %q", string(e)) + return fmt.Sprintf("invalid header field value for %q", string(e)) } var ( @@ -2864,7 +2863,8 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFr fr.debugReadLoggerf("http2: decoded hpack field %+v", hf) } if !httpguts.ValidHeaderFieldValue(hf.Value) { - invalid = http2headerFieldValueError(hf.Value) + // Don't include the value in the error, because it may be sensitive. + invalid = http2headerFieldValueError(hf.Name) } isPseudo := strings.HasPrefix(hf.Name, ":") if isPseudo { @@ -3583,8 +3583,8 @@ func (s *http2sorter) SortStrings(ss []string) { // validPseudoPath reports whether v is a valid :path pseudo-header // value. It must be either: // -// *) a non-empty string starting with '/' -// *) the string '*', for OPTIONS requests. +// - 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. @@ -4119,7 +4119,7 @@ func (s *http2Server) ServeConn(c net.Conn, opts *http2ServeConnOpts) { if s.NewWriteScheduler != nil { sc.writeSched = s.NewWriteScheduler() } else { - sc.writeSched = http2NewRandomWriteScheduler() + sc.writeSched = http2NewPriorityWriteScheduler(nil) } // These start at the RFC-specified defaults. If there is a higher @@ -6040,17 +6040,18 @@ type http2requestBody struct { _ http2incomparable stream *http2stream conn *http2serverConn - closed bool // for use by Close only + closeOnce sync.Once // for use by Close only sawEOF bool // for use by Read only pipe *http2pipe // non-nil if we have a HTTP entity message body needsContinue bool // need to send a 100-continue } func (b *http2requestBody) Close() error { - if b.pipe != nil && !b.closed { - b.pipe.BreakWithError(http2errClosedBody) - } - b.closed = true + b.closeOnce.Do(func() { + if b.pipe != nil { + b.pipe.BreakWithError(http2errClosedBody) + } + }) return nil } @@ -7221,12 +7222,14 @@ func (t *http2Transport) RoundTripOpt(req *Request, opt http2RoundTripOpt) (*Res if req, err = http2shouldRetryRequest(req, err); err == nil { // After the first retry, do exponential backoff with 10% jitter. if retry == 0 { + t.vlogf("RoundTrip retrying after failure: %v", err) continue } backoff := float64(uint(1) << (uint(retry) - 1)) backoff += backoff * (0.1 * mathrand.Float64()) select { case <-time.After(time.Second * time.Duration(backoff)): + t.vlogf("RoundTrip retrying after failure: %v", err) continue case <-req.Context().Done(): err = req.Context().Err() @@ -7452,10 +7455,13 @@ func (cc *http2ClientConn) healthCheck() { // trigger the healthCheck again if there is no frame received. ctx, cancel := context.WithTimeout(context.Background(), pingTimeout) defer cancel() + cc.vlogf("http2: Transport sending health check") err := cc.Ping(ctx) if err != nil { + cc.vlogf("http2: Transport health check failure: %v", err) cc.closeForLostPing() - return + } else { + cc.vlogf("http2: Transport health check success") } } @@ -8485,7 +8491,8 @@ func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trail } for _, v := range vv { if !httpguts.ValidHeaderFieldValue(v) { - return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k) + // Don't include the value in the error, because it may be sensitive. + return nil, fmt.Errorf("invalid HTTP header value for header %q", k) } } } @@ -9618,7 +9625,13 @@ func (t *http2Transport) logf(format string, args ...interface{}) { log.Printf(format, args...) } -var http2noBody io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil)) +var http2noBody io.ReadCloser = http2noBodyReader{} + +type http2noBodyReader struct{} + +func (http2noBodyReader) Close() error { return nil } + +func (http2noBodyReader) Read([]byte) (int, error) { return 0, io.EOF } type http2missingBody struct{} @@ -9639,7 +9652,9 @@ type http2erringRoundTripper struct{ err error } func (rt http2erringRoundTripper) RoundTripErr() error { return rt.err } -func (rt http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { return nil, rt.err } +func (rt http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { + return nil, rt.err +} // gzipReader wraps a response body so it can lazily // call gzip.NewReader on the first call to Read |
