go/src/net/http/httputil/dump.go

// drainBody reads all of b to memory and then returns two equivalent
// ReadClosers yielding the same bytes.
//
// It returns an error if the initial slurp of all bytes fails. It does not attempt
// to make the returned ReadClosers have identical error-matching behavior.
func drainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error) {}

type dumpConn

func (c *dumpConn) Close() error                       {}

func (c *dumpConn) LocalAddr() net.Addr                {}

func (c *dumpConn) RemoteAddr() net.Addr               {}

func (c *dumpConn) SetDeadline(t time.Time) error      {}

func (c *dumpConn) SetReadDeadline(t time.Time) error  {}

func (c *dumpConn) SetWriteDeadline(t time.Time) error {}

type neverEnding

func (b neverEnding) Read(p []byte) (n int, err error) {}

// outgoingLength is a copy of the unexported
// (*http.Request).outgoingLength method.
func outgoingLength(req *http.Request) int64 {}

// 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) {}

type delegateReader

func (r *delegateReader) Read(p []byte) (int, error) {}

// Return value if nonempty, def otherwise.
func valueOrDefault(value, def string) string {}

var reqWriteExcludeHeaderDump

// DumpRequest returns the given request in its HTTP/1.x wire
// representation. It should only be used by servers to debug client
// requests. The returned representation is an approximation only;
// some details of the initial request are lost while parsing it into
// an [http.Request]. In particular, the order and case of header field
// names are lost. The order of values in multi-valued headers is kept
// intact. HTTP/2 requests are dumped in HTTP/1.x form, not in their
// original binary representations.
//
// If body is true, DumpRequest also returns the body. To do so, it
// consumes req.Body and then replaces it with a new [io.ReadCloser]
// that yields the same bytes. If DumpRequest returns an error,
// the state of req is undefined.
//
// The documentation for [http.Request.Write] details which fields
// of req are included in the dump.
func DumpRequest(req *http.Request, body bool) ([]byte, error) {}

var errNoBody

type failureToReadBody

func (failureToReadBody) Read([]byte) (int, error) {}

func (failureToReadBody) Close() error             {}

var emptyBody

// DumpResponse is like DumpRequest but dumps a response.
func DumpResponse(resp *http.Response, body bool) ([]byte, error) {}