File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 1111
1212(defn url-encode
1313 " Wrapper around java.net.URLEncoder returning a (UTF-8) URL encoded
14- representation of text."
15- [text]
16- (URLEncoder/encode text " UTF-8" ))
17-
18- (defn- encode-body-map
19- " Turns a map into a URL-encoded string suitable for a request body."
20- [body]
21- (str-join " &" (map #(str-join " =" (map url-encode %)) body)))
14+ representation of argument, either a string or map."
15+ [arg]
16+ (if (map? arg)
17+ (str-join \& (map #(str-join \= (map url-encode %)) arg))
18+ (URLEncoder/encode (as-str arg) " UTF-8" )))
2219
2320(defn- send-body
2421 [body connection headers]
@@ -36,7 +33,7 @@ representation of text."
3633 (let [out (.getOutputStream connection)]
3734 (cond
3835 (string? body) (spit out body)
39- (map? body) (spit out (encode-body-map body))
36+ (map? body) (spit out (url-encode body))
4037 (instance? InputStream body) (let [bytes (make-array Byte/TYPE 1000 )]
4138 (loop [bytes-read (.read body bytes)]
4239 (when (pos? bytes-read)
You can’t perform that action at this time.
0 commit comments