Permalink
Browse files

Merge remote-tracking branch 'toofishes/reflection-warn'

  • Loading branch information...
dakrone committed Oct 16, 2012
2 parents 797676d + 71065f9 commit 9f8cff5a84f8d94409d80ebe755e498231343570
Showing with 14 additions and 14 deletions.
  1. +1 −1 src/clj_http/lite/client.clj
  2. +10 −10 src/clj_http/lite/core.clj
  3. +3 −3 src/clj_http/lite/util.clj
@@ -103,7 +103,7 @@
(if body
(cond
(string? body)
- (client (-> req (assoc :body (.getBytes body)
+ (client (-> req (assoc :body (.getBytes ^String body)
:character-encoding (or body-encoding
"UTF-8"))))
:else
View
@@ -1,8 +1,8 @@
(ns clj-http.lite.core
"Core HTTP request/response implementation."
(:require [clojure.java.io :as io])
- (:import (java.io ByteArrayOutputStream IOException)
- (java.net URI URL)))
+ (:import (java.io ByteArrayOutputStream InputStream IOException)
+ (java.net URI URL HttpURLConnection)))
(defn parse-headers
"Takes a URLConnection and returns a map of names to values.
@@ -12,12 +12,12 @@
in the headers."
[conn]
(loop [i 1 headers {}]
- (let [k (.getHeaderFieldKey conn i)
- v (.getHeaderField conn i)]
+ (let [k (.getHeaderFieldKey ^HttpURLConnection conn i)
+ v (.getHeaderField ^HttpURLConnection conn i)]
(if k
(recur (inc i) (update-in headers [k] conj v))
(zipmap (for [k (keys headers)]
- (.toLowerCase k))
+ (.toLowerCase ^String k))
(for [v (vals headers)]
(if (= 1 (count v))
(first v)
@@ -28,12 +28,12 @@
stream that closes itself and the connection manager when closed."
[{:keys [as]} conn]
(let [ins (try
- (.getInputStream conn)
+ (.getInputStream ^HttpURLConnection conn)
(catch Exception e
- (.getErrorStream conn)))]
+ (.getErrorStream ^HttpURLConnection conn)))]
(if (= :stream as)
ins
- (with-open [ins ins
+ (with-open [ins ^InputStream ins
baos (ByteArrayOutputStream.)]
(io/copy ins baos)
(.flush baos)
@@ -61,7 +61,7 @@
(.setRequestProperty conn "Content-Type" content-type))
(doseq [[h v] headers]
(.setRequestProperty conn h v))
- (.setRequestMethod conn (.toUpperCase (name request-method)))
+ (.setRequestMethod ^HttpURLConnection conn (.toUpperCase (name request-method)))
(when body
(.setDoOutput conn true))
(when socket-timeout
@@ -71,7 +71,7 @@
(with-open [out (.getOutputStream conn)]
(io/copy body out)))
(merge {:headers (parse-headers conn)
- :status (.getResponseCode conn)
+ :status (.getResponseCode ^HttpURLConnection conn)
:body (when-not (= request-method :head)
(coerce-body-entity req conn))}
(when save-request?
@@ -1,7 +1,7 @@
(ns clj-http.lite.util
"Helper functions for the HTTP client."
(:require [clojure.java.io :as io])
- (:import (java.io ByteArrayInputStream ByteArrayOutputStream)
+ (:import (java.io ByteArrayInputStream ByteArrayOutputStream InputStream)
(java.net URLEncoder URLDecoder)
(java.util.zip InflaterInputStream DeflaterInputStream
GZIPInputStream GZIPOutputStream)))
@@ -38,10 +38,10 @@
(let [chunk-size 8192
baos (ByteArrayOutputStream.)
buffer (byte-array chunk-size)]
- (loop [len (.read is buffer 0 chunk-size)]
+ (loop [len (.read ^InputStream is buffer 0 chunk-size)]
(when (not= -1 len)
(.write baos buffer 0 len)
- (recur (.read is buffer 0 chunk-size))))
+ (recur (.read ^InputStream is buffer 0 chunk-size))))
(.toByteArray baos)))

0 comments on commit 9f8cff5

Please sign in to comment.