diff options
Diffstat (limited to 'src/clojure/contrib/http/connection.clj')
-rw-r--r-- | src/clojure/contrib/http/connection.clj | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/clojure/contrib/http/connection.clj b/src/clojure/contrib/http/connection.clj index 0e975cd9..4eda0fa6 100644 --- a/src/clojure/contrib/http/connection.clj +++ b/src/clojure/contrib/http/connection.clj @@ -27,32 +27,32 @@ #^{:doc "Transmits a request entity body."} send-request-entity (fn [conn entity] (type entity))) -(defmethod send-request-entity duck/*byte-array-type* [conn entity] +(defmethod send-request-entity duck/*byte-array-type* [#^HttpURLConnection conn entity] (.setFixedLengthStreamingMode conn (count entity)) (.connect conn) (duck/copy entity (.getOutputStream conn))) -(defmethod send-request-entity String [conn entity] +(defmethod send-request-entity String [conn #^String entity] (send-request-entity conn (.getBytes entity duck/*default-encoding*))) -(defmethod send-request-entity File [conn entity] +(defmethod send-request-entity File [#^HttpURLConnection conn #^File entity] (.setFixedLengthStreamingMode conn (.length entity)) (.connect conn) (duck/copy entity (.getOutputStream conn))) -(defmethod send-request-entity InputStream [conn entity] +(defmethod send-request-entity InputStream [#^HttpURLConnection conn entity] (.setChunkedStreamingMode conn -1) (.connect conn) (duck/copy entity (.getOutputStream conn))) -(defmethod send-request-entity Reader [conn entity] +(defmethod send-request-entity Reader [#^HttpURLConnection conn entity] (.setChunkedStreamingMode conn -1) (.connect conn) (duck/copy entity (.getOutputStream conn))) (defn start-http-connection - ([conn] (.connect conn)) - ([conn request-entity-body] + ([#^HttpURLConnection conn] (.connect conn)) + ([#^HttpURLConnection conn request-entity-body] (if request-entity-body (do (.setDoOutput conn true) (send-request-entity conn request-entity-body)) |