File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 11(ns clojure.http.client
22 (:use [clojure.contrib.java-utils :only [as-str]]
33 [clojure.contrib.duck-streams :only [read-lines spit]]
4- [clojure.contrib.str-utils :only [str-join]])
4+ [clojure.contrib.str-utils :only [str-join]]
5+ [clojure.contrib.base64 :as base64])
56 (:import (java.net URL
67 URLEncoder
78 HttpURLConnection)
@@ -106,8 +107,9 @@ by a server."
106107 [u & [method headers cookies body]]
107108 ; ; This function *should* throw an exception on non-HTTP URLs.
108109 ; ; This will happen if the cast fails.
109- (let [#^HttpURLConnection connection
110- (cast HttpURLConnection (.openConnection (url u)))
110+ (let [u (url u)
111+ #^HttpURLConnection connection
112+ (cast HttpURLConnection (.openConnection u))
111113 method (.toUpperCase #^String (as-str (or method
112114 " GET" )))]
113115 (.setRequestMethod connection method)
@@ -122,6 +124,13 @@ by a server."
122124 (.setRequestProperty connection
123125 " Cookie"
124126 (create-cookie-string cookies)))
127+
128+ (when (.getUserInfo u)
129+ (.setRequestProperty connection
130+ " Authorization"
131+ (str " Basic "
132+ (base64/encode-str (.getUserInfo u)))))
133+
125134 (if body
126135 (send-body body connection headers)
127136 (.connect connection))
You can’t perform that action at this time.
0 commit comments