Do I need to close the stream in case of exception?
Open
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.8k
- Forks
- 410
- PR merge metrics
- No merged PRs in 30d
Description
According to the docs, when I receive a stream from the server, the connection hangs until I consume the whole stream:
;; Return the body as a stream
(client/get "http://example.com/bigrequest.html" {:as :stream})
;; Note that the connection to the server will NOT be closed until the
;; stream has been read
My question is, what will happen in case of non-200 exception? Do I still need to close the stream properly? I added the following code:
(try
(clj-http.client/get "http://non-existing-url" {:as :stream})
(catch Exception e
(some-> e ex-data :body .close)))
But I'm still not sure if I need that.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the documented client/get example using {:as :stream}, then trace the exception data's :body and its .close call in the provided example. Clarify in the documentation whether a stream must be closed after a non-200 response, and update the example or guidance so completion is verifiable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api, backend, networking
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100