Allow 'content' of types other than alist in lack.test:generate-env.

This commit is contained in:
Eitaro Fukamachi 2018-09-19 22:53:39 +09:00
parent 17756b63fd
commit 4fac568329

View file

@ -33,7 +33,7 @@
;; default headers ;; default headers
(setf headers (append `(("host" . ,host) ("accept" . "*/*")) headers)) (setf headers (append `(("host" . ,host) ("accept" . "*/*")) headers))
(when content (when content
(let ((content-type (or (cdr (assoc "content-type" headers :test #'string-equal)) (let ((content-type (or (cdr (assoc "content-type" headers :test #'string-equal))
(if (find-if #'pathnamep content :key #'cdr) (if (find-if #'pathnamep content :key #'cdr)
@ -50,9 +50,15 @@
(format s "~A=~A" (caar cookies) (cdar cookies)) (format s "~A=~A" (caar cookies) (cdar cookies))
(loop for (k . v) in (cdr cookies) (loop for (k . v) in (cdr cookies)
do (format s "; ~A=~A" k v)))))))) do (format s "; ~A=~A" k v))))))))
(when content (setf content
(setf content (flex:string-to-octets (etypecase content
(quri:url-encode-params content)))) (cons (flex:string-to-octets
(quri:url-encode-params content)
:external-format :utf-8))
(string (flex:string-to-octets content
:external-format :utf-8))
(array content)
(null nil)))
(list :request-method method (list :request-method method
;; Seems that all Clack handlers put into this field ;; Seems that all Clack handlers put into this field
;; only pathname with GET parameters ;; only pathname with GET parameters