Permalink
Browse files
Fixed multipart-params bug that occurs with Clojure 1.3.0
- Loading branch information...
Showing
with
11 additions
and
14 deletions.
-
+11
−14
ring-core/src/ring/middleware/multipart_params.clj
|
|
@@ -38,26 +38,23 @@ |
|
|
(.getItemIterator (FileUpload.) context)))
|
|
|
|
|
|
(defn- parse-file-item
|
|
|
- "Parse a FileItemStream into a parameter value. If the request is a file the
|
|
|
+ "Parse a FileItemStream into a key-value pair. If the request is a file the
|
|
|
supplied store function is used to save it."
|
|
|
[^FileItemStream item store]
|
|
|
- (if (.isFormField item)
|
|
|
- (Streams/asString (.openStream item))
|
|
|
- (store {:filename (.getName item)
|
|
|
- :content-type (.getContentType item)
|
|
|
- :stream (.openStream item)})))
|
|
|
+ [(.getFieldName item)
|
|
|
+ (if (.isFormField item)
|
|
|
+ (Streams/asString (.openStream item))
|
|
|
+ (store {:filename (.getName item)
|
|
|
+ :content-type (.getContentType item)
|
|
|
+ :stream (.openStream item)}))])
|
|
|
|
|
|
(defn- parse-multipart-params
|
|
|
"Parse a map of multipart parameters from the request."
|
|
|
[request encoding store]
|
|
|
- (reduce
|
|
|
- (fn [params item]
|
|
|
- (assoc-param params
|
|
|
- (.getFieldName item)
|
|
|
- (parse-file-item item store)))
|
|
|
- {}
|
|
|
- (file-item-seq
|
|
|
- (request-context request encoding))))
|
|
|
+ (->> (request-context request encoding)
|
|
|
+ (file-item-seq)
|
|
|
+ (map #(parse-file-item % store))
|
|
|
+ (reduce (fn [m [k v]] (assoc-param m k v)) {})))
|
|
|
|
|
|
(defn- load-var
|
|
|
"Returns the var named by the supplied symbol, or nil if not found. Attempts
|
|
|
|
0 comments on commit
40cd236