diff options
Diffstat (limited to 'decoders.lisp')
-rw-r--r-- | decoders.lisp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/decoders.lisp b/decoders.lisp index d6bb7d6..9878b44 100644 --- a/decoders.lisp +++ b/decoders.lisp @@ -114,7 +114,6 @@ becomes (:content-disposition (:name \"file\" :filename \"mypic.png\"))") (<<result parts))) (defun decode-multipart/form-data (stream content-type content-length) - (declare (ignore content-length)) (let* ((boundary (concatenate 'string "--" (second (split-sequence:split-sequence #\= content-type)))) (stream (make-instance 'replay-streams:static-text-replay-stream @@ -122,3 +121,18 @@ becomes (:content-disposition (:name \"file\" :filename \"mypic.png\"))") (parse stream (<<multipart/form-data boundary)))) (add-decoder "multipart/form-data" #'decode-multipart/form-data) + +;;; APPLICATION/X-WWW-FORM-URLENCODED + +(defun decode-application/x-www-form-urlencoded (stream content-type content-length) + (declare (ignore content-type)) + (->> (read-body-to-string stream content-length) + (split-sequence #\&) + (mapcar (lambda (s) (split-sequence #\= s))) + (as->* pairs + (loop + :for (key undecoded) :in pairs + :appending (list (make-keyword key) + (urldecode undecoded :queryp t)))))) + +(add-decoder "application/x-www-form-urlencoded" #'decode-application/x-www-form-urlencoded) |