A small Go HTTP reverse-proxy recorder for capturing request and response traffic to a local directory.
http-recorder listens on a configurable local address, forwards requests to an upstream target, and saves each captured request/response pair under a timestamped folder.
This is useful for debugging upstream HTTP services, testing registries, or inspecting exact request and response payloads.
go install github.com/qq1u/http-recorder@latestThen run:
http-recorderhttp-recorder -target https://registry.npmjs.org/ -address :8080 -dir http-target: upstream URL to forward traffic to; default:https://registry.npmjs.org/-address: local listen address; default::8080-dir: output directory for saved records; default:http
The program:
- removes
Accept-Encodingfrom outbound requests - adds
X-Forwarded-*headers - rewrites requests to the configured target URL
- trims leading and trailing
/from the request path before creating a record folder - dumps the raw request and response bodies into files in the output directory
For a request like /, the generated directory name is:
<timestamp>_GET
For a request like /api/user, it becomes:
<timestamp>_GET_user
That folder is created under the configured -dir, so the effective structure is:
http/
<timestamp>_GET/
request.txt
response.txt
Start the recorder:
http-recorder -target https://registry.npmjs.org/ -address :8080 -dir httpnpm install is-number --registry='http://localhost:8080' --cache "$env:TEMP\npm-cache-$(Get-Random)" --prefer-online --loglevel=httpnpm install is-number --registry='http://localhost:8080' --cache "${TMPDIR:-/tmp}/npm-cache-$(date +%s)" --prefer-online --loglevel=httpThe --cache flag is optional, but using a unique cache directory per run helps force a fresh download and makes it easier to verify that the proxy is in use.
Request GET /
Response GET /
Target: "https://registry.npmjs.org/", Relayer listening on :8080