aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/httptest
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2016-08-30 03:19:01 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2016-09-01 04:26:12 +0000
commitd24f446a90ea94b87591bf16228d7d871fec3d92 (patch)
treed1a9b8d8f77bd8223ddb7d46c73321569b28e9a0 /src/net/http/httptest
parentcd0ba4c169b591cc22f51cb61463eb45af7b930d (diff)
downloadgo-d24f446a90ea94b87591bf16228d7d871fec3d92.tar.xz
crypto/tls: add Config.Clone
In Go 1.0, the Config struct consisted only of exported fields. In Go 1.1, it started to grow private, uncopyable fields (sync.Once, sync.Mutex, etc). Ever since, people have been writing their own private Config.Clone methods, or risking it and doing a language-level shallow copy and copying the unexported sync variables. Clean this up and export the Config.clone method as Config.Clone. This matches the convention of Template.Clone from text/template and html/template at least. Fixes #15771 Updates #16228 (needs update in x/net/http2 before fixed) Updates #16492 (not sure whether @agl wants to do more) Change-Id: I48c2825d4fef55a75d2f99640a7079c56fce39ca Reviewed-on: https://go-review.googlesource.com/28075 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/net/http/httptest')
-rw-r--r--src/net/http/httptest/server.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/http/httptest/server.go b/src/net/http/httptest/server.go
index 8608077bd1..e67b7145be 100644
--- a/src/net/http/httptest/server.go
+++ b/src/net/http/httptest/server.go
@@ -114,9 +114,10 @@ func (s *Server) StartTLS() {
}
existingConfig := s.TLS
- s.TLS = new(tls.Config)
if existingConfig != nil {
- *s.TLS = *existingConfig
+ s.TLS = existingConfig.Clone()
+ } else {
+ s.TLS = new(tls.Config)
}
if s.TLS.NextProtos == nil {
s.TLS.NextProtos = []string{"http/1.1"}