From: Brad Fitzpatrick Date: Tue, 16 Dec 2014 06:47:55 +0000 (+1100) Subject: net/http/httputil: don't use DisableKeepAlives in DumpRequestOut, fix build X-Git-Tag: go1.5beta1~2618 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8f36655346396e32952c6a7c9cfbc16c73a1ff4d;p=gostls13.git net/http/httputil: don't use DisableKeepAlives in DumpRequestOut, fix build I broke the build in https://golang.org/change/207950a when I made http.Transport send "Connection: close" request headers when DisableKeepAlives was set true because I didn't run all the tests before submitting. httputil.DumpRequestOut used Transport to get its output, and used it with DisableKeepAlives, so this changed the output. Rather than updating golden data in our tests (because surely others depend on the exact bytes from these in their tests), switch to not using DisableKeepAlives in DumpRequestOut instead, so the output is the same as before. Change-Id: I9fad190be8032e55872e6947802055a6d65244df Reviewed-on: https://go-review.googlesource.com/1632 Reviewed-by: Andrew Gerrand --- diff --git a/src/net/http/httputil/dump.go b/src/net/http/httputil/dump.go index ac8f103f9b..ca2d1cde92 100644 --- a/src/net/http/httputil/dump.go +++ b/src/net/http/httputil/dump.go @@ -98,6 +98,14 @@ func DumpRequestOut(req *http.Request, body bool) ([]byte, error) { defer pr.Close() defer pw.Close() dr := &delegateReader{c: make(chan io.Reader)} + + t := &http.Transport{ + Dial: func(net, addr string) (net.Conn, error) { + return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil + }, + } + defer t.CloseIdleConnections() + // Wait for the request before replying with a dummy response: go func() { req, err := http.ReadRequest(bufio.NewReader(pr)) @@ -107,16 +115,9 @@ func DumpRequestOut(req *http.Request, body bool) ([]byte, error) { io.Copy(ioutil.Discard, req.Body) req.Body.Close() } - dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\n\r\n") + dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n") }() - t := &http.Transport{ - DisableKeepAlives: true, - Dial: func(net, addr string) (net.Conn, error) { - return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil - }, - } - _, err := t.RoundTrip(reqSend) req.Body = save