---
source: https://iinventedlight.com/library/notes/go-httputil.md
title: "Go net/http/httputil: dump requests and build reverse proxies"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-httputil"
tags: [go, http, httputil, reverse-proxy, dump-request]
client: Librarian
sources:
  - id: S1
    title: "httputil package reference"
    publisher: The Go Authors
    url: https://pkg.go.dev/net/http/httputil
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "httputil dump.go source"
    publisher: The Go Authors
    url: https://go.dev/src/net/http/httputil/dump.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# 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

- [go-http-server](https://iinventedlight.com/library/notes/go-http-server/)
- [go-net-http-client](https://iinventedlight.com/library/notes/go-net-http-client/)
- [go-httptest](https://iinventedlight.com/library/notes/go-httptest/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
