Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ metadata/update/DNS/TLS inspection modes, and executes requests via `src/http`.
- Output-file downloads keep `*.download` temp files behind a drop guard so cancellation paths such as Ctrl-C clean up partial files; Unix atomic installs also sync the parent directory after rename/link updates for stronger crash durability.
- Image rendering defaults (`auto`) use built-in Rust decoders only; external adapters (`vips`, `magick`, `ffmpeg`) require `--image external` or `image = external` and run with bounded stdin/stdout/stderr and timeout handling.
- Response compression negotiation is controlled by `--compress auto|br|gzip|zstd|off` or `compress = ...`; `brotli` is accepted as an alias for `br`, `auto` requests and decodes gzip/brotli/zstd, single-algorithm modes only request/decode that algorithm, and `off` leaves compressed bodies untouched.
- Formatted SSE responses stream incrementally to stdout with terminal color when enabled, rendering events as `event:`/`data:` blocks while formatting JSON data. Auto-compressed SSE responses are retried without `Accept-Encoding` so intermediaries do not buffer events; request timeouts from flags, curl commands, or config remain enforced.
- Digest authentication retries drain oversized 401 challenge bodies with a fixed bound; on Windows, the authenticated retry is sent before the partially drained challenge response is dropped so the local TCP abort from abandoning the first response cannot poison the follow-up request.
- `--sort-headers` or `sort-headers = true` sorts displayed request/response headers alphabetically by name in verbose output without changing the actual request header order.
- Default HTTP requests send `Accept: application/json, */*;q=0.5`, preferring JSON while allowing any other response type as a lower-priority fallback.
- `--basic` and `--digest` credentials preserve exact bytes around the first colon; leading/trailing spaces in usernames or passwords are significant and are not trimmed after CLI or `--from-curl` parsing.
Expand Down
9 changes: 9 additions & 0 deletions docs/advanced-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ Compression modes:
- `zstd` requests and decompresses zstd only
- `off` sends no automatic `Accept-Encoding` header and leaves compressed response bodies untouched

For SSE (`text/event-stream`) responses in `auto` mode, `fetch` retries without
`Accept-Encoding` when the server replies with compressed content. This avoids
common buffering behavior that prevents events from appearing as they arrive.

Using `off` is useful when:

- Testing compression behavior
Expand Down Expand Up @@ -385,6 +389,11 @@ The timeout covers:
- Connection establishment
- TLS handshake
- Request/response transfer
- Streamed response bodies such as SSE, NDJSON, and gRPC streams

Timeouts from CLI flags, `--from-curl`, and configuration files are enforced for
streaming responses. Omit `--timeout` or use a larger value for long-lived event
streams.

### `--connect-timeout SECONDS`

Expand Down
8 changes: 7 additions & 1 deletion docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ fetch --connect-timeout 5 --timeout 30 example.com

### `-t, --timeout SECONDS`

Request timeout in seconds. Accepts decimal values.
Request timeout in seconds. Accepts decimal values. The timeout covers the full
request, including response body streaming; it is also enforced for SSE, NDJSON,
and gRPC streams.

```sh
fetch --timeout 30 example.com
Expand Down Expand Up @@ -465,6 +467,10 @@ Control response compression negotiation. Values: `auto`, `br`/`brotli`, `gzip`,
- `zstd` - request zstd compression only
- `off` - disable automatic compression negotiation and decompression

In `auto` mode, compressed SSE (`text/event-stream`) responses are retried
without `Accept-Encoding` so streaming events can be delivered promptly instead
of being buffered by compression.

```sh
fetch --compress br example.com
fetch --compress gzip example.com
Expand Down
7 changes: 6 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ connect-timeout = 2.5
**Type**: Number (seconds)
**Default**: None (no timeout)

Set a timeout for HTTP requests. Accepts decimal values.
Set a timeout for HTTP requests. Accepts decimal values. This timeout covers the
full request, including streamed response bodies such as SSE, NDJSON, and gRPC
streams.

```ini
# 30 second timeout
Expand Down Expand Up @@ -491,6 +493,9 @@ compress = zstd
compress = off
```

When `compress = auto`, compressed SSE (`text/event-stream`) responses are
retried without `Accept-Encoding` so events can be displayed as they arrive.

### Session Options

#### `session`
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fetch httpbin.org/json | jq '.slideshow.title'
- **YAML** - Syntax highlighted
- **Images** - Rendered directly in supported terminals
- **Protobuf / msgpack** - Decoded and displayed as JSON
- **SSE / NDJSON** - Streamed line-by-line
- **SSE / NDJSON** - Streamed as events or lines arrive

See [Output Formatting](output-formatting.md) for details.

Expand Down
13 changes: 10 additions & 3 deletions docs/output-formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ See [gRPC documentation](grpc.md) for schema-aware formatting.
Features:

- Streaming output as events arrive
- Event type and data parsing
- SSE-shaped `event:` and `data:` output
- JSON `data:` payloads are formatted and syntax-highlighted
- Request timeouts still apply to long-running event streams

```sh
fetch example.com/events
Expand All @@ -246,12 +248,17 @@ Output:

```
event: message
data: {"user": "john", "text": "Hello!"}
data: { "text": "Hello!", "user": "john" }

event: message
data: {"user": "jane", "text": "Hi there!"}
data: { "text": "Hi there!", "user": "jane" }
```

When color is enabled, `event` and `data` labels are highlighted, and JSON values
inside `data:` use the same syntax highlighting as JSON responses. In automatic
compression mode, compressed SSE responses are retried without `Accept-Encoding`
so proxies and servers are less likely to buffer events before delivery.

### NDJSON / JSON Lines

**Content-Types**: `application/x-ndjson`, `application/ndjson`, `application/x-jsonl`, `application/jsonl`, `application/x-jsonlines`
Expand Down
Loading
Loading