aboutsummaryrefslogtreecommitdiff
path: root/decoders.lisp
diff options
context:
space:
mode:
authorCoin Okay <cbeok@protonmail.com>2020-04-24 18:40:48 -0500
committerCoin Okay <cbeok@protonmail.com>2020-04-24 18:40:48 -0500
commit2aa6bca29e6a2782a789cdf6fc2cfdfbcb06a628 (patch)
treea6acb56d678b5710e5bce588e181a4ab3cbbf054 /decoders.lisp
parent45e0812d602f5c2cae845ba0cb280b94291ed860 (diff)
application/x-www-form-urlencoded decoder
Diffstat (limited to 'decoders.lisp')
-rw-r--r--decoders.lisp16
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)