Skip to content

[#8] fix reflection warning #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(defproject org.martinklepsch/clj-http-lite "0.4.3"
:description "A Clojure HTTP library similar to clj-http, but more lightweight."
:url "https://github.com/martinklepsch/clj-http-lite/"
:warn-on-reflection false
:license {:name "MIT"
:url "http://www.opensource.org/licenses/mit-license.php"}
:dependencies [[org.clojure/clojure "1.8.0"]
Expand Down
2 changes: 2 additions & 0 deletions src/clj_http/lite/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
(java.net URL UnknownHostException))
(:refer-clojure :exclude (get update)))

(set! *warn-on-reflection* true)

(defn update [m k f & args]
(assoc m k (apply f (m k) args)))

Expand Down
10 changes: 6 additions & 4 deletions src/clj_http/lite/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
(:import (java.io ByteArrayOutputStream InputStream IOException)
(java.net URI URL HttpURLConnection)))

(set! *warn-on-reflection* true)

(defn parse-headers
"Takes a URLConnection and returns a map of names to values.

Expand Down Expand Up @@ -53,7 +55,7 @@
(when server-port (str ":" server-port))
uri
(when query-string (str "?" query-string)))
conn (.openConnection ^URL (URL. http-url))]
^HttpURLConnection conn (.openConnection ^URL (URL. http-url))]
(when (and content-type character-encoding)
(.setRequestProperty conn "Content-Type" (str content-type
"; charset="
Expand All @@ -63,8 +65,8 @@
(doseq [[h v] headers]
(.setRequestProperty conn h v))
(when (false? follow-redirects)
(.setInstanceFollowRedirects ^HttpURLConnection conn false))
(.setRequestMethod ^HttpURLConnection conn (.toUpperCase (name request-method)))
(.setInstanceFollowRedirects conn false))
(.setRequestMethod conn (.toUpperCase (name request-method)))
(when body
(.setDoOutput conn true))
(when socket-timeout
Expand All @@ -78,7 +80,7 @@
(with-open [out (.getOutputStream conn)]
(io/copy body out)))
(merge {:headers (parse-headers conn)
:status (.getResponseCode ^HttpURLConnection conn)
:status (.getResponseCode conn)
:body (when-not (= request-method :head)
(coerce-body-entity req conn))}
(when save-request?
Expand Down
2 changes: 2 additions & 0 deletions src/clj_http/lite/links.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Imported from https://github.com/dakrone/clj-http/blob/217393258e7863514debece4eb7b23a7a3fa8bd9/src/clj_http/links.clj")

(set! *warn-on-reflection* true)

(def ^:private quoted-string
#"\"((?:[^\"]|\\\")*)\"")

Expand Down
2 changes: 2 additions & 0 deletions src/clj_http/lite/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
(java.util.zip InflaterInputStream DeflaterInputStream
GZIPInputStream GZIPOutputStream)))

(set! *warn-on-reflection* true)

(defn utf8-bytes
"Returns the UTF-8 bytes corresponding to the given string."
[#^String s]
Expand Down