Skip to content

Commit

Permalink
Prevent the parsing of empty streams
Browse files Browse the repository at this point in the history
This bug was raised against ztellman/aleph here:
clj-commons/aleph#331
  • Loading branch information
Antony Woods committed Nov 2, 2017
1 parent f4b2844 commit 72e6ac2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/clj_http/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@
"Resolve and apply Transit's JSON/MessagePack decoding."
[in type & [opts]]
{:pre [transit-enabled?]}
(let [reader (ns-resolve 'cognitect.transit 'reader)
read (ns-resolve 'cognitect.transit 'read)]
(read (reader in type (transit-read-opts opts)))))
(when (pos? (.available in))
(let [reader (ns-resolve 'cognitect.transit 'reader)
read (ns-resolve 'cognitect.transit 'read)]
(read (reader in type (transit-read-opts opts))))))

(defn ^:dynamic transit-encode
"Resolve and apply Transit's JSON/MessagePack encoding."
Expand Down

0 comments on commit 72e6ac2

Please sign in to comment.