mirror of
https://github.com/vale981/lack
synced 2025-03-05 09:21: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))))
|
||||
|
||||
;; 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))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue