Skip to content

Commit 5507f63

Browse files
committed
fixed body-seq to not cause an exception if there's no body in the response from the server
1 parent e0e8a56 commit 5507f63

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/clojure/http/client.clj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
(:use [clojure.contrib.java-utils :only [as-str]]
33
[clojure.contrib.duck-streams :only [read-lines]]
44
[clojure.contrib.str-utils :only [str-join]])
5-
(:import (java.net URL HttpURLConnection URLEncoder))))
5+
(:import (java.net URL HttpURLConnection URLEncoder)
6+
(java.io StringReader)))
67

78
(def default-headers {"User-Agent" (str "Clojure/" (clojure-version)
89
" (+http://clojure.org)"),
@@ -27,9 +28,10 @@ url as its sole argument."
2728
"Returns a lazy-seq of lines from either the input stream
2829
or the error stream of connection, whichever is appropriate."
2930
[connection]
30-
(read-lines (if (>= (.getResponseCode connection) 400)
31-
(.getErrorStream connection)
32-
(.getInputStream connection))))
31+
(read-lines (or (if (>= (.getResponseCode connection) 400)
32+
(.getErrorStream connection)
33+
(.getInputStream connection))
34+
(StringReader. ""))))
3335

3436
(defn- parse-headers
3537
"Returns a map of the response headers from connection."

0 commit comments

Comments
 (0)