Skip to content

Commit b32b3c9

Browse files
committed
Only set Content-Type header when sending a request body if we haven't already set one up above; if the user wants a custom Content-Type AND to send a request body we should allow it.
1 parent 6e1c2db commit b32b3c9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/clojure/http/client.clj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ by a server."
9292
(if body
9393
(do
9494
(.setDoOutput connection true)
95-
(.setRequestProperty connection
96-
"Content-Type"
97-
"application/x-www-form-urlencoded")
95+
;; this isn't perfect, since it doesn't account for
96+
;; different capitalization etc
97+
(when-not (contains? headers "Content-Type")
98+
(.setRequestProperty connection
99+
"Content-Type"
100+
"application/x-www-form-urlencoded"))
98101
(.connect connection)
99102
(spit (.getOutputStream connection)
100103
(encode-body body)))

0 commit comments

Comments
 (0)