mirror of
https://github.com/golang/go
synced 2024-11-24 02:50:11 -07:00
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 <bradfitz@golang.org>
This commit is contained in:
parent
07314714c0
commit
9f60a0a2b0
@ -55,9 +55,9 @@ func (b neverEnding) Read(p []byte) (n int, err error) {
|
|||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpRequestOut is like DumpRequest but includes
|
// DumpRequestOut is like DumpRequest but for outgoing client requests. It
|
||||||
// headers that the standard http.Transport adds,
|
// includes any headers that the standard http.Transport adds, such as
|
||||||
// such as User-Agent.
|
// User-Agent.
|
||||||
func DumpRequestOut(req *http.Request, body bool) ([]byte, error) {
|
func DumpRequestOut(req *http.Request, body bool) ([]byte, error) {
|
||||||
save := req.Body
|
save := req.Body
|
||||||
dummyBody := false
|
dummyBody := false
|
||||||
@ -175,8 +175,10 @@ func dumpAsReceived(req *http.Request, w io.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpRequest returns the as-received wire representation of req,
|
// DumpRequest returns the as-received wire representation of req, optionally
|
||||||
// optionally including the request body, for debugging.
|
// 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
|
// DumpRequest is semantically a no-op, but in order to
|
||||||
// dump the body, it reads the body data into memory and
|
// dump the body, it reads the body data into memory and
|
||||||
// changes req.Body to refer to the in-memory copy.
|
// changes req.Body to refer to the in-memory copy.
|
||||||
|
Loading…
Reference in New Issue
Block a user