diff options
Diffstat (limited to 'lazybones-hunchentoot.lisp')
-rw-r--r-- | lazybones-hunchentoot.lisp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lazybones-hunchentoot.lisp b/lazybones-hunchentoot.lisp index 38480a0..2b3bf1e 100644 --- a/lazybones-hunchentoot.lisp +++ b/lazybones-hunchentoot.lisp @@ -208,7 +208,20 @@ HEADER-NAME can be a keyword or a string." (defun request-body (&key (request lzb:*request*) (want-stream-p nil)) "Returns the decoded request body. The value returned depends upon -the value of the Content-Type request header." +the value of the Content-Type request header. + +If WANT-STREAM-P is non-null, then an attempt is made to return a +stream from which the body content can be read. This may be impossible +if the Content-Type of the request is one of multipart/form-data or +application/x-www-form-urlencoded. + +If the body's Content-Type is application/json, multipart/form-data, +or application/x-www-form-urlencoded then a property-list +representation of the body is returned. + +Otherwise a bytevector of the body is returned. + +Work to unpack the body is performed once per request. Calling this" (if %request-body-cache% %request-body-cache% (setf %request-body-cache% (when (member (request-method request) +hunchentoot-methods-with-body+) @@ -230,7 +243,9 @@ the value of the Content-Type request header." ((string-equal "application/json" content-type) (jonathan:parse - (h:raw-post-data :request request :external-format :utf8 ))) ;TODO: don't hardcode utf8 + (h:raw-post-data :request request :external-format :utf8) + :as :plist + :keywords-to-read *allowed-keywords*)) (t ;; default case is to return a bytevector |