           (let [mp-entity (MultipartEntity.)]
             (doseq [[k v] multipart]
               (.addPart mp-entity (name k) (ByteArrayBody. v (name k))))
-            (.setEntity #^HttpEntityEnclosingRequest http-req mp-entity))
+            (.setEntity #^HttpEntityEnclosingRequest http-req
+                        (create-multipart-entity multipart)))
           (when body
             (let [http-body (ByteArrayEntity. body)]
               (.setEntity #^HttpEntityEnclosingRequest http-req http-body))))

  (if insecure?
    (SingleClientConnManager. insecure-scheme-registry)
    (SingleClientConnManager.)))

(defn request
  "Executes the HTTP request corresponding to the given Ring request map and

(ns clj-http.core
  "Core HTTP request/response implementation."
  (:require [clojure.pprint])
  (:import (java.io File InputStream)
           (java.net URI)
           (org.apache.http HttpRequest HttpEntityEnclosingRequest
                            HttpResponse Header HttpHost)
           (org.apache.http.util EntityUtils)
           (org.apache.http.entity ByteArrayEntity)
           (org.apache.http.entity.mime MultipartEntity)
           (org.apache.http.entity.mime.content ByteArrayBody
                                                FileBody
                                                InputStreamBody
                                                StringBody)
           (org.apache.http.client HttpClient)
           (org.apache.http.client.methods HttpGet HttpHead HttpPut
                                           HttpPost HttpDelete
