Reference

HTTP & network inspection

Decode requests, responses, browser rules and network diagnostics.

Scope and conventions

Wire examples use HTTP/1.1 notation; HTTP/2 and HTTP/3 encode it differently. Commands use a Unix-like shell and illustrative example.test hosts. Browser security behavior is labeled separately from HTTP and command-line clients.

Client inspection

Show response headers and body

HTTP & tools

-i includes response headers. -D writes headers separately; -o chooses a body output file. -sS hides progress while retaining errors.

Fragment

HTTP & tools · Show response headers and body
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
curl -sS -i https://api.example.test/items
curl -sS -D headers.txt -o body.json \
  https://api.example.test/items

-v emits connection and request details, which may contain credentials.

HEAD is a different request

HTTP & tools

-I sends HEAD and displays headers. To inspect headers from a real GET without saving its body, use -D - with -o /dev/null.

Fragment

HTTP & tools · HEAD is a different request
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
curl -I https://api.example.test/items
curl -sS -D - -o /dev/null \
  https://api.example.test/items

A server can handle HEAD and GET differently; choose the method you intend to diagnose.

Send JSON or URL-encoded query values

HTTP & tools

--data-binary sends the supplied bytes, selecting POST by default. --get with --data-urlencode constructs a GET query.

Fragment

HTTP & tools · Send JSON or URL-encoded query values
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
curl -sS -H 'Content-Type: application/json' \
  --data-binary '{"name":"red tea"}' \
  https://api.example.test/items

curl -sS --get --data-urlencode 'q=red tea & milk' \
  https://api.example.test/items

Separate HTTP errors from transport errors

HTTP & tools

By default, curl can exit successfully after receiving HTTP 404 or 500. --fail-with-body makes HTTP errors fail while retaining the body. --connect-timeout and --max-time bound different stages.

Fragment

HTTP & tools · Separate HTTP errors from transport errors
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
curl --fail-with-body --connect-timeout 3 --max-time 10 \
  https://api.example.test/items

--fail-with-body requires curl 7.76+. Authentication cases have documented caveats.

Follow and inspect redirects

HTTP & tools

-L follows redirects. -w can print the final status and effective URL; -o /dev/null discards body bytes.

Fragment

HTTP & tools · Follow and inspect redirects
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
curl -sS -L -o /dev/null \
  -w '%{http_code} %{url_effective}\n' \
  https://api.example.test/items

Redirect options and HTTP method affect replay behavior. Avoid --location-trusted unless credential forwarding is explicitly intended.

Check HTTP status after Fetch resolves

HTTP & tools

Fetch rejects for network-level failures and aborts, not ordinary 4xx/5xx statuses. response.ok covers 200–299. Read the body in its expected format.

Fragment

HTTP & tools · Check HTTP status after Fetch resolves
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const response = await fetch("/api/items");
if (!response.ok) {
  throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();

A body stream is normally consumed once. Runtime validation is still needed for parsed JSON.

Cancel a browser request

HTTP & tools

AbortController signals cancellation to Fetch. Aborting client work does not prove that server-side processing was rolled back.

Fragment

HTTP & tools · Cancel a browser request
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const controller = new AbortController();
const request = fetch("/api/items", {
  signal: controller.signal
});
controller.abort();
// Await/catch request in the owning task.