Skip to content

Commit 61024fe

Browse files
committed
Oops; don't hard-code request body in.
1 parent bd14bdc commit 61024fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/clojure/http/client.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ representation of text."
2020
[body]
2121
(str-join "&" (map #(str-join "=" (map url-encode %)) body)))
2222

23+
(defn- encode-body [body]
24+
(if (string? body)
25+
body
26+
(encode-body-map body)))
27+
2328
(defn url
2429
"If u is an instance of java.net.URL then returns it without
2530
modification, otherwise tries to instantiate a java.net.URL with
@@ -94,7 +99,7 @@ by a server."
9499
"application/x-www-form-urlencoded")
95100
(.connect connection)
96101
(with-open [out (writer (.getOutputStream connection))]
97-
(.write out "{ hello: \"world\" }")
102+
(.write out (encode-body body))
98103
(.flush out)))
99104
(.connect connection))
100105

0 commit comments

Comments
 (0)