From: Aaron Jacobs Date: Wed, 14 Oct 2015 23:25:56 +0000 (+1100) Subject: net/http/httputil: clarify where DumpRequest(Out)? can be used. X-Git-Tag: go1.6beta1~839 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9f60a0a2b01c9d1079ea8991125b471cdaa7eb56;p=gostls13.git net/http/httputil: clarify where DumpRequest(Out)? can be used. The clues to this were already there, but as a user I was still unsure. Make this more explicit. Change-Id: I68564f3498dcd4897772a303588f03a6b65f111d Reviewed-on: https://go-review.googlesource.com/15172 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/net/http/httputil/dump.go b/src/net/http/httputil/dump.go index ca2d1cde92..0a7003d3eb 100644 --- a/src/net/http/httputil/dump.go +++ b/src/net/http/httputil/dump.go @@ -55,9 +55,9 @@ func (b neverEnding) Read(p []byte) (n int, err error) { return len(p), nil } -// DumpRequestOut is like DumpRequest but includes -// headers that the standard http.Transport adds, -// such as User-Agent. +// DumpRequestOut is like DumpRequest but for outgoing client requests. It +// includes any headers that the standard http.Transport adds, such as +// User-Agent. func DumpRequestOut(req *http.Request, body bool) ([]byte, error) { save := req.Body dummyBody := false @@ -175,8 +175,10 @@ func dumpAsReceived(req *http.Request, w io.Writer) error { return nil } -// DumpRequest returns the as-received wire representation of req, -// optionally including the request body, for debugging. +// DumpRequest returns the as-received wire representation of req, optionally +// including the request body, for debugging. It is for use in servers; use +// DumpRequestOut for client requests. +// // DumpRequest is semantically a no-op, but in order to // dump the body, it reads the body data into memory and // changes req.Body to refer to the in-memory copy.