net/http: drop custom tls.Config cloning code.
Now that we have the Clone method on tls.Config, net/http doesn't need any custom functions to do that any more. Change-Id: Ib60707d37f1a7f9a7d7723045f83e59eceffd026 Reviewed-on: https://go-review.googlesource.com/31595 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
83797dffac
commit
56db2e9d77
@ -455,9 +455,13 @@ func ticketKeyFromBytes(b [32]byte) (key ticketKey) {
|
|||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone returns a shallow clone of c.
|
// Clone returns a shallow clone of c. It is safe to clone a Config that is
|
||||||
// Only the exported fields are copied.
|
// being used concurrently by a TLS client or server.
|
||||||
func (c *Config) Clone() *Config {
|
func (c *Config) Clone() *Config {
|
||||||
|
// Running serverInit ensures that it's safe to read
|
||||||
|
// SessionTicketsDisabled.
|
||||||
|
c.serverInitOnce.Do(c.serverInit)
|
||||||
|
|
||||||
var sessionTicketKeys []ticketKey
|
var sessionTicketKeys []ticketKey
|
||||||
c.mutex.RLock()
|
c.mutex.RLock()
|
||||||
sessionTicketKeys = c.sessionTicketKeys
|
sessionTicketKeys = c.sessionTicketKeys
|
||||||
|
@ -508,6 +508,10 @@ func TestClone(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c2 := c1.Clone()
|
c2 := c1.Clone()
|
||||||
|
// DeepEqual also compares unexported fields, thus c2 needs to have run
|
||||||
|
// serverInit in order to be DeepEqual to c1. Cloning it and discarding
|
||||||
|
// the result is sufficient.
|
||||||
|
c2.Clone()
|
||||||
|
|
||||||
if !reflect.DeepEqual(&c1, c2) {
|
if !reflect.DeepEqual(&c1, c2) {
|
||||||
t.Errorf("clone failed to copy a field")
|
t.Errorf("clone failed to copy a field")
|
||||||
|
Loading…
Reference in New Issue
Block a user