From 037b7060e7def3abe446d54ad4ff23838e68f10d Mon Sep 17 00:00:00 2001 From: Eitaro Fukamachi Date: Fri, 13 Mar 2015 10:56:34 +0900 Subject: [PATCH] Store parsed query-parameters, body-parameters and cookies in ENV. --- src/request.lisp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/request.lisp b/src/request.lisp index aa75d6c..663ff69 100644 --- a/src/request.lisp +++ b/src/request.lisp @@ -62,27 +62,33 @@ (setf uri (getf env :request-uri)))) ;; Cookies - (let* ((headers (request-headers req)) - (cookie (and (hash-table-p headers) - (gethash "cookie" headers)))) - (when cookie - (setf (request-cookies req) - (loop for kv in (ppcre:split "\\s*[,;]\\s*" cookie) - append (quri:url-decode-params kv :lenient t))))) + (unless (request-cookies req) + (let* ((headers (request-headers req)) + (cookie (and (hash-table-p headers) + (gethash "cookie" headers)))) + (when cookie + (setf (request-cookies req) + (loop for kv in (ppcre:split "\\s*[,;]\\s*" cookie) + append (quri:url-decode-params kv :lenient t))) + (setf (getf env :cookies) (request-cookies req))))) ;; GET parameters (with-slots (query-parameters query-string) req (when (and (null query-parameters) query-string) (setf query-parameters - (quri:url-decode-params query-string :lenient t)))) + (quri:url-decode-params query-string :lenient t)) + (setf (getf env :query-parameters) query-parameters))) ;; POST parameters (with-slots (body-parameters raw-body content-length content-type) req (when (and (null body-parameters) raw-body) (setf body-parameters - (http-body:parse content-type content-length raw-body)))) + (http-body:parse content-type content-length raw-body)) + (setf (getf env :body-parameters) body-parameters))) + + (setf (request-env req) env) req))