hubcap network - Stream network requests and responses

When to use

Monitor network requests and responses in real time as NDJSON. Use har for standard HAR format output suitable for analysis tools. Use waitrequest or waitresponse to block until a specific network event occurs.

Usage

hubcap network [--duration <duration>]

Arguments

None.

Flags

FlagTypeDefaultDescription
--durationduration0How long to capture; 0 = until interrupted

Output

NDJSON stream written to stdout. Each line is a JSON object representing either a request or a response.

FieldTypeDescription
typestring"request" or "response"
requestIdstringUnique identifier for the request/response pair
urlstringRequest URL
methodstringHTTP method (request lines only)
statusintHTTP status code (response lines only)
mimeTypestringResponse MIME type (response lines only)

Request line:

{"type":"request","requestId":"1000.1","method":"GET","url":"https://example.com/api/data"}

Response line:

{"type":"response","requestId":"1000.1","status":200,"mimeType":"application/json"}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Invalid flag value1invalid value "..." for flag -duration: ...

Examples

Stream all network activity until Ctrl-C:

hubcap network

Capture network activity for 10 seconds:

hubcap network --duration 10s

Filter for API requests using jq:

hubcap network --duration 30s | jq 'select(.type == "request" and (.url | contains("/api/")))'

Get the response body for a captured request:

hubcap network --duration 5s | jq -r 'select(.type == "response" and .status == 200) | .requestId' | head -1 | xargs hubcap responsebody

See also

  • har - Capture network activity in HAR format
  • responsebody - Get the response body for a captured request
  • waitrequest - Wait for a specific network request
  • waitresponse - Wait for a specific network response
  • block - Block network requests by URL pattern
  • intercept - Intercept and modify network requests or responses