Skip to content
Browse files

Add set-system-proxy\! function, allowing the use of a proxy server i…

…n HTTP requests.
  • Loading branch information...
1 parent 01f52c2 commit c917372254a2edb22bfa82bc273452cb70d203d0 Richard Newman committed
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/clojure/http/client.clj
View
10 src/clojure/http/client.clj
@@ -9,6 +9,16 @@
" (+http://clojure.org)"),
"Connection" "close"})
+(defn set-system-proxy!
+ "Java's HttpURLConnection cannot do per-request proxying. Instead,
+ system properties are used. This function mutates the global setting.
+ For per-request proxying, use the Apache HTTP client."
+ [#^String host port]
+ (doto (System/getProperties)
+ (.setProperty "http.proxyHost" host)
+ (.setProperty "http.proxyPort" (str port)))
+ nil)
+
(defn url-encode
"Wrapper around java.net.URLEncoder returning a (UTF-8) URL encoded
representation of argument, either a string or map."

0 comments on commit c917372

Please sign in to comment.
Something went wrong with that request. Please try again.