Skip to content
This repository has been archived by the owner on Jan 23, 2018. It is now read-only.

Commit

Permalink
fixed body-seq to not cause an exception if there's no body in the re…
Browse files Browse the repository at this point in the history
…sponse from the server
  • Loading branch information
danlarkin committed May 5, 2009
1 parent e0e8a56 commit 5507f63
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/clojure/http/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:use [clojure.contrib.java-utils :only [as-str]]
[clojure.contrib.duck-streams :only [read-lines]]
[clojure.contrib.str-utils :only [str-join]])
(:import (java.net URL HttpURLConnection URLEncoder))))
(:import (java.net URL HttpURLConnection URLEncoder)
(java.io StringReader)))

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

(defn- parse-headers
"Returns a map of the response headers from connection."
Expand Down

0 comments on commit 5507f63

Please sign in to comment.