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
- id: C1 claim: The package provides HTTP utility functions that complement net/http. source: S1 evidence: "provides HTTP utility functions, complementing the more common ones"
- id: C2 claim: DumpRequest should only be used by servers to debug client requests. source: S1 evidence: "only be used by servers to debug client requests"
- id: C3 claim: DumpRequestOut is for outgoing client requests. source: S2 evidence: "but for outgoing client requests"
- id: C4 claim: DumpResponse dumps a response. source: S2 evidence: "DumpRequest but dumps a response"
Sources
- [S1] httputil package reference. The Go Authors. https://pkg.go.dev/net/http/httputil . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] httputil dump.go source. The Go Authors. https://go.dev/src/net/http/httputil/dump.go . License: BSD-3-Clause. Accessed 2026-11-24.
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
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.},
}
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.
- go-httputil.schema.json (schema; CC-BY-4.0)
- go-httputil.table.json (table; CC-BY-4.0)
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.