Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: flaky TestTransportHeadChunkedResponse #11122

Closed
bradfitz opened this issue Jun 9, 2015 · 2 comments
Closed

net/http: flaky TestTransportHeadChunkedResponse #11122

bradfitz opened this issue Jun 9, 2015 · 2 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

bradfitz commented Jun 9, 2015

Noticed at http://build.golang.org/log/c4295893036b8f63339f2fdcfa6a7f052edbdfa4

--- FAIL: TestTransportHeadChunkedResponse-4 (0.02s)
    transport_test.go:611: ip/ports differed between head requests: "127.0.0.1:54643" vs "127.0.0.1:54644"
FAIL
FAIL    net/http    10.889s

The test is simply:

        defer afterTest(t)
        ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
                if r.Method != "HEAD" {
                        panic("expected HEAD; got " + r.Method)
                }
                w.Header().Set("Transfer-Encoding", "chunked") // client should ignore                                                     
                w.Header().Set("x-client-ipport", r.RemoteAddr)
                w.WriteHeader(200)
        }))
        defer ts.Close()

        tr := &Transport{DisableKeepAlives: false}
        c := &Client{Transport: tr}

        res1, err := c.Head(ts.URL)
        if err != nil {
                t.Fatalf("request 1 error: %v", err)
        }
        res2, err := c.Head(ts.URL)
        if err != nil {
                t.Fatalf("request 2 error: %v", err)
        }
        if v1, v2 := res1.Header.Get("x-client-ipport"), res2.Header.Get("x-client-ipport"); v1 != v2 {
                t.Errorf("ip/ports differed between head requests: %q vs %q", v1, v2)
        }
}

Perhaps the first Head returns but the second Head call starts before the background Transport goroutines get scheduled and register that the connection is idle.

@tzneal
Copy link
Member

tzneal commented Jun 17, 2015

@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

Dup of #11250, closed.

@rsc rsc closed this as completed Jun 29, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe Jul 9, 2015
@golang golang locked and limited conversation to collaborators Jul 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants