hubcap responsebody - Get the response body for a network request

When to use

Get the response body for a previously captured network request. Use the requestId from network or har output to identify which response to retrieve.

Usage

hubcap responsebody <requestId>

Arguments

ArgumentTypeRequiredDescription
requestIdstringYesRequest identifier from network or har output

Flags

None.

Output

The response body content object.

FieldTypeDescription
bodystringResponse body content
base64EncodedboolWhether the body is base64-encoded
{"body":"{\"status\":\"ok\",\"data\":[1,2,3]}","base64Encoded":false}

Errors

ConditionExit codeStderr
Missing requestId argument1usage: hubcap responsebody <requestId>
Protocol error1error: getting response body: ...
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Get the response body for a specific request ID:

hubcap responsebody "1000.1"

Extract the decoded body content:

hubcap responsebody "1000.1" | jq -r '.body'

Capture network traffic and then retrieve the body for the first JSON response:

REQUEST_ID=$(hubcap network --duration 5s | jq -r 'select(.type == "response" and .mimeType == "application/json") | .requestId' | head -1)
hubcap responsebody "$REQUEST_ID" | jq -r '.body' | jq .

See also

  • network - Stream network requests and responses
  • har - Capture network activity in HAR format
  • intercept - Intercept and modify network requests or responses
  • waitresponse - Wait for a specific network response