]> Cypherpunks repositories - gostls13.git/commitdiff
http: fix IP confusion in TestServerTimeouts
authorRuss Cox <rsc@golang.org>
Mon, 18 Apr 2011 20:03:24 +0000 (16:03 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 18 Apr 2011 20:03:24 +0000 (16:03 -0400)
Don't assume that localhost == 127.0.0.1.
It might be ::1.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4430055

src/pkg/http/serve_test.go

index 4dce3781de4e6e89032a1d1bfc227153b6409539..c3c7b8d33002870022b2b7708f04a25c2e31b480 100644 (file)
@@ -247,7 +247,7 @@ func TestServerTimeouts(t *testing.T) {
        server := &Server{Handler: handler, ReadTimeout: 0.25 * second, WriteTimeout: 0.25 * second}
        go server.Serve(l)
 
-       url := fmt.Sprintf("http://localhost:%d/", addr.Port)
+       url := fmt.Sprintf("http://%s/", addr)
 
        // Hit the HTTP server successfully.
        tr := &Transport{DisableKeepAlives: true} // they interfere with this test
@@ -265,7 +265,7 @@ func TestServerTimeouts(t *testing.T) {
 
        // Slow client that should timeout.
        t1 := time.Nanoseconds()
-       conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", addr.Port))
+       conn, err := net.Dial("tcp", addr.String())
        if err != nil {
                t.Fatalf("Dial: %v", err)
        }