1
0
mirror of https://github.com/golang/go synced 2024-11-12 06:30:21 -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:
Brad Fitzpatrick 2011-09-21 08:30:47 -07:00
parent 1262f6bde7
commit 96f968df9c

View File

@ -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) { func TestTLSServer(t *testing.T) {
ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
if r.TLS != nil { if r.TLS != nil {