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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ For chunked or long-running responses, use `Client.request-stream` to get a
(match (ResponseStream.poll &stream)
(Maybe.Nothing) (break)
(Maybe.Just chunk) (IO.print &chunk)))
(when (Maybe.just? (ResponseStream.error &stream))
(IO.errorln "the response body was truncated"))
(ResponseStream.close stream))
(Result.Error e) (IO.errorln &e))
```
Expand All @@ -82,6 +84,15 @@ For chunked or long-running responses, use `Client.request-stream` to get a
implements the `poll` interface from the
[streams](https://github.com/carpentry-org/streams) library.

`poll` returns `Nothing` at the end of a well-formed body and also when the
framing or the transport failed part-way through it; `ResponseStream.error`
tells the two apart. The buffered request functions (`Client.get`,
`Client.request`, and friends) fold that into their result, so a malformed
chunked body, or a `Content-Length` body that ends short, comes back as
`(Result.Error …)` rather than a short body with a 200 on it. A body delimited
only by the connection closing declares no length to check against, so it is
taken as complete however the connection ends.

### Cookie jar

Use a `CookieJar` to store cookies from responses and replay them on
Expand Down
Loading