aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/http/httputil/dump.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/http/httputil/dump.go')
-rw-r--r--libgo/go/net/http/httputil/dump.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/libgo/go/net/http/httputil/dump.go b/libgo/go/net/http/httputil/dump.go
index c853066f1cf..892ef4eded0 100644
--- a/libgo/go/net/http/httputil/dump.go
+++ b/libgo/go/net/http/httputil/dump.go
@@ -12,6 +12,7 @@ import (
"io/ioutil"
"net"
"net/http"
+ "net/url"
"strings"
"time"
)
@@ -59,6 +60,19 @@ func DumpRequestOut(req *http.Request, body bool) ([]byte, error) {
}
}
+ // Since we're using the actual Transport code to write the request,
+ // switch to http so the Transport doesn't try to do an SSL
+ // negotiation with our dumpConn and its bytes.Buffer & pipe.
+ // The wire format for https and http are the same, anyway.
+ reqSend := req
+ if req.URL.Scheme == "https" {
+ reqSend = new(http.Request)
+ *reqSend = *req
+ reqSend.URL = new(url.URL)
+ *reqSend.URL = *req.URL
+ reqSend.URL.Scheme = "http"
+ }
+
// Use the actual Transport code to record what we would send
// on the wire, but not using TCP. Use a Transport with a
// customer dialer that returns a fake net.Conn that waits
@@ -79,7 +93,7 @@ func DumpRequestOut(req *http.Request, body bool) ([]byte, error) {
},
}
- _, err := t.RoundTrip(req)
+ _, err := t.RoundTrip(reqSend)
req.Body = save
if err != nil {