mirror of
https://github.com/vale981/lack
synced 2025-03-05 17:31:39 -05:00
Store parsed query-parameters, body-parameters and cookies in ENV.
This commit is contained in:
parent
e9a3c4c9a0
commit
037b7060e7
1 changed files with 15 additions and 9 deletions
|
@ -62,27 +62,33 @@
|
||||||
(setf uri (getf env :request-uri))))
|
(setf uri (getf env :request-uri))))
|
||||||
|
|
||||||
;; Cookies
|
;; Cookies
|
||||||
(let* ((headers (request-headers req))
|
(unless (request-cookies req)
|
||||||
(cookie (and (hash-table-p headers)
|
(let* ((headers (request-headers req))
|
||||||
(gethash "cookie" headers))))
|
(cookie (and (hash-table-p headers)
|
||||||
(when cookie
|
(gethash "cookie" headers))))
|
||||||
(setf (request-cookies req)
|
(when cookie
|
||||||
(loop for kv in (ppcre:split "\\s*[,;]\\s*" cookie)
|
(setf (request-cookies req)
|
||||||
append (quri:url-decode-params kv :lenient t)))))
|
(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
|
;; GET parameters
|
||||||
(with-slots (query-parameters query-string) req
|
(with-slots (query-parameters query-string) req
|
||||||
(when (and (null query-parameters)
|
(when (and (null query-parameters)
|
||||||
query-string)
|
query-string)
|
||||||
(setf query-parameters
|
(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
|
;; POST parameters
|
||||||
(with-slots (body-parameters raw-body content-length content-type) req
|
(with-slots (body-parameters raw-body content-length content-type) req
|
||||||
(when (and (null body-parameters)
|
(when (and (null body-parameters)
|
||||||
raw-body)
|
raw-body)
|
||||||
(setf body-parameters
|
(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))
|
req))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue