Skip to content

About

HTTP recorder

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-recorder

A small Go HTTP reverse-proxy recorder for capturing request and response traffic to a local directory.

Overview

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.

Install

go install github.com/qq1u/http-recorder@latest

Then run:

http-recorder

Usage

http-recorder -target https://registry.npmjs.org/ -address :8080 -dir http

Flags

  • -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

Behavior

The program:

  • removes Accept-Encoding from 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

Output layout

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

Example

Start the recorder:

http-recorder -target https://registry.npmjs.org/ -address :8080 -dir http

Windows PowerShell

npm install is-number --registry='http://localhost:8080' --cache "$env:TEMP\npm-cache-$(Get-Random)" --prefer-online --loglevel=http

Linux / macOS

npm install is-number --registry='http://localhost:8080' --cache "${TMPDIR:-/tmp}/npm-cache-$(date +%s)" --prefer-online --loglevel=http

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

Example log output

Request GET /
Response GET /
Target: "https://registry.npmjs.org/", Relayer listening on :8080

About

HTTP recorder

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages