aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/request_test.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2020-11-13 03:04:52 +0100
committerFilippo Valsorda <filippo@golang.org>2020-11-13 03:04:52 +0100
commit11087322f85d5ace6494fc194982d92f0a34df0f (patch)
tree1fc71e2b2e13647ad4a2a86f95794b47ca950e99 /src/net/http/request_test.go
parented9dc25d693c02aeeb8ed084b28b6d7f9489dc5a (diff)
parentc53315d6cf1b4bfea6ff356b4a1524778c683bb9 (diff)
downloadgo-11087322f85d5ace6494fc194982d92f0a34df0f.tar.gz
go-11087322f85d5ace6494fc194982d92f0a34df0f.zip
[dev.boringcrypto.go1.15] all: merge go1.15.5 into dev.boringcrypto.go1.15
Change-Id: I075fd29b5d035cac905c7bc3145405bf622a981b
Diffstat (limited to 'src/net/http/request_test.go')
-rw-r--r--src/net/http/request_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/net/http/request_test.go b/src/net/http/request_test.go
index 42c16d00ea..461d66e05d 100644
--- a/src/net/http/request_test.go
+++ b/src/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)
}