diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-11-07 07:25:23 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-10 07:25:32 -0800 |
commit | cf392dbdf17e38026f8e3c0e9af7f5b87f63be56 (patch) | |
tree | 6b1df9cdc36cc47b6164db69a14bc86a63dc77c6 /libgo/go/net | |
parent | 0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739 (diff) | |
download | gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.zip gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.tar.gz gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.tar.bz2 |
libgo: update to Go 1.15.4 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/268177
Diffstat (limited to 'libgo/go/net')
-rw-r--r-- | libgo/go/net/http/h2_bundle.go | 11 | ||||
-rw-r--r-- | libgo/go/net/http/request.go | 2 | ||||
-rw-r--r-- | libgo/go/net/http/request_test.go | 21 |
3 files changed, 33 insertions, 1 deletions
diff --git a/libgo/go/net/http/h2_bundle.go b/libgo/go/net/http/h2_bundle.go index 779da4f..71592e9 100644 --- a/libgo/go/net/http/h2_bundle.go +++ b/libgo/go/net/http/h2_bundle.go @@ -5265,6 +5265,7 @@ func (sc *http2serverConn) processData(f *http2DataFrame) error { if len(data) > 0 { wrote, err := st.body.Write(data) if err != nil { + sc.sendWindowUpdate(nil, int(f.Length)-wrote) return http2streamError(id, http2ErrCodeStreamClosed) } if wrote != len(data) { @@ -7167,6 +7168,7 @@ func (t *http2Transport) newClientConn(c net.Conn, singleUse bool) (*http2Client cc.inflow.add(http2transportDefaultConnFlow + http2initialWindowSize) cc.bw.Flush() if cc.werr != nil { + cc.Close() return nil, cc.werr } @@ -7532,6 +7534,15 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe bodyWriter := cc.t.getBodyWriterState(cs, body) cs.on100 = bodyWriter.on100 + defer func() { + cc.wmu.Lock() + werr := cc.werr + cc.wmu.Unlock() + if werr != nil { + cc.Close() + } + }() + cc.wmu.Lock() endStream := !hasBody && !hasTrailers werr := cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs) diff --git a/libgo/go/net/http/request.go b/libgo/go/net/http/request.go index fe6b6098..54ec1c5 100644 --- a/libgo/go/net/http/request.go +++ b/libgo/go/net/http/request.go @@ -382,7 +382,7 @@ func (r *Request) Clone(ctx context.Context) *Request { if s := r.TransferEncoding; s != nil { s2 := make([]string, len(s)) copy(s2, s) - r2.TransferEncoding = s + r2.TransferEncoding = s2 } r2.Form = cloneURLValues(r.Form) r2.PostForm = cloneURLValues(r.PostForm) diff --git a/libgo/go/net/http/request_test.go b/libgo/go/net/http/request_test.go index 42c16d0..461d66e 100644 --- a/libgo/go/net/http/request_test.go +++ b/libgo/go/net/http/request_test.go @@ -828,6 +828,27 @@ func TestWithContextDeepCopiesURL(t *testing.T) { } } +// Ensure that Request.Clone creates a deep copy of TransferEncoding. +// See issue 41907. +func TestRequestCloneTransferEncoding(t *testing.T) { + body := strings.NewReader("body") + req, _ := NewRequest("POST", "https://example.org/", body) + req.TransferEncoding = []string{ + "encoding1", + } + + clonedReq := req.Clone(context.Background()) + // modify original after deep copy + req.TransferEncoding[0] = "encoding2" + + if req.TransferEncoding[0] != "encoding2" { + t.Error("expected req.TransferEncoding to be changed") + } + if clonedReq.TransferEncoding[0] != "encoding1" { + t.Error("expected clonedReq.TransferEncoding to be unchanged") + } +} + func TestNoPanicOnRoundTripWithBasicAuth_h1(t *testing.T) { testNoPanicWithBasicAuth(t, h1Mode) } |