← All notes

Go net/http/httputil: dump requests and build reverse proxies

Answer: The package provides HTTP utility functions, complementing the more common ones in net/http.

Dumping inbound traffic

DumpRequest can print a request in HTTP 1.x wire form.

It should only be used by servers to debug client requests.

The dump is only an approximation, and some header order and case is lost.

Passing true for body includes the request body in the dump.

Outbound dumps and internals

DumpRequestOut is like DumpRequest but for outgoing client requests.

It also keeps headers that Transport would add, including User-Agent.

DumpResponse does the same kind of dump for a response.

drainBody reads all of a body to memory and then returns two equivalent ReadClosers yielding the same bytes.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, httputil package reference; The Go Authors, httputil dump.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, httputil package reference; The Go Authors, httputil dump.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:05ngj0ha

iinventedlight. 2026. "Go net/http/httputil: dump requests and build reverse proxies." iinventedlight Library, iil:note:05ngj0ha, version of 2026-11-24. https://iinventedlight.com/library/notes/go-httputil/. License: CC-BY-4.0.

@misc{iil_note_05ngj0ha,
  author = {{iinventedlight}},
  title = {{Go net/http/httputil: dump requests and build reverse proxies}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/go-httputil/},
  note = {Permanent ID iil:note:05ngj0ha. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-httputil.md.