mirror of
https://github.com/golang/go
synced 2024-11-22 02:14:40 -07:00
http: add a (disabled) test for TLS handshake timeouts
It's currently broken and disabled, pending a fix for Issue 2281. R=golang-dev, adg CC=golang-dev https://golang.org/cl/5092045
This commit is contained in:
parent
1262f6bde7
commit
96f968df9c
@ -535,6 +535,30 @@ func TestHeadResponses(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTLSHandshakeTimeout(t *testing.T) {
|
||||
if true {
|
||||
t.Logf("Skipping broken test; issue 2281")
|
||||
return
|
||||
}
|
||||
ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {}))
|
||||
ts.Config.ReadTimeout = 250e6
|
||||
ts.StartTLS()
|
||||
defer ts.Close()
|
||||
conn, err := net.Dial("tcp", ts.Listener.Addr().String())
|
||||
if err != nil {
|
||||
t.Fatalf("Dial: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
timer := time.AfterFunc(10e9, func() { t.Fatalf("Timeout") })
|
||||
defer timer.Stop()
|
||||
|
||||
var buf [1]byte
|
||||
n, err := conn.Read(buf[:])
|
||||
if err == nil || n != 0 {
|
||||
t.Errorf("Read = %d, %v; want an error and no bytes", n, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTLSServer(t *testing.T) {
|
||||
ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
|
||||
if r.TLS != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user