Skip to content

Commit

Permalink
remove reflection from body-entity
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed Feb 4, 2012
1 parent 255f511 commit e4ad622
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.org
Expand Up @@ -73,6 +73,7 @@
per-request proxy settings
- remove a few more reflections
- added ablity to return the body as a stream with {:as :stream}
- general code cleanup
** Release 0.3.0
** 2012-01-31
- add ability to ignore unknown host if desired ({:ignore-unknown-host? true})
Expand Down
9 changes: 5 additions & 4 deletions src/clj_http/core.clj
@@ -1,7 +1,7 @@
(ns clj-http.core
"Core HTTP request/response implementation."
(:require [clojure.pprint])
(:import (java.io File InputStream)
(:import (java.io File FilterInputStream InputStream)
(java.net URI)
(org.apache.http HeaderIterator HttpRequest HttpEntity
HttpEntityEnclosingRequest
Expand All @@ -18,6 +18,7 @@
HttpPost HttpDelete
HttpEntityEnclosingRequestBase)
(org.apache.http.client.params CookiePolicy ClientPNames)
(org.apache.http.conn ClientConnectionManager)
(org.apache.http.conn.params ConnRoutePNames)
(org.apache.http.conn.scheme PlainSocketFactory
SchemeRegistry Scheme)
Expand Down Expand Up @@ -143,10 +144,10 @@
(defn- coerce-body-entity
"Coerce the http-entity from an HttpResponse to either a byte-array, or a
stream that closes itself and the connection manager when closed."
[{:keys [as]} http-entity conn-mgr]
[{:keys [as]} ^HttpEntity http-entity ^ClientConnectionManager conn-mgr]
(when http-entity
(if (= :stream as)
(proxy [java.io.FilterInputStream]
(proxy [FilterInputStream]
[(.getContent http-entity)]
(close []
(try
Expand Down Expand Up @@ -215,7 +216,7 @@
:body (coerce-body-entity req http-entity conn-mgr)}]
(when (and (instance? SingleClientConnManager conn-mgr)
(not= :stream as))
(.shutdown conn-mgr))
(.shutdown ^ClientConnectionManager conn-mgr))
(if save-request?
(-> resp
(assoc :request req)
Expand Down

0 comments on commit e4ad622

Please sign in to comment.