Skip to content

Commit cb2e5ac

Browse files
committed
.
1 parent 2e6d592 commit cb2e5ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cookbook/http.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ http get https://api.example.com/data.json | metadata | get http_response.status
270270
To work with metadata while streaming the response body, use `metadata access`. This is useful for handling unexpected responses (errors, redirects, content negotiation) without consuming the entire body:
271271

272272
```nu
273-
# Log status and headers while streaming a large file
274-
http get https://api.example.com/large-dataset.csv
273+
# Log status and headers while streaming a large JSONL file
274+
http get https://api.example.com/events.jsonl
275275
| metadata access {|meta|
276276
print $"Status: ($meta.http_response.status)"
277277
print $"Content-Type: ($meta.http_response.headers | where name == content-type | get value.0)"
@@ -281,8 +281,8 @@ http get https://api.example.com/large-dataset.csv
281281
} else { }
282282
}
283283
| lines
284-
| from csv
285-
| where amount > 1000
284+
| each { from json }
285+
| where event_type == "error"
286286
```
287287

288288
The response body streams through the pipeline—you can inspect metadata and process the stream simultaneously. Before `metadata access`, you needed `--full` to get metadata, which consumed the entire body and prevented streaming.

0 commit comments

Comments
 (0)