aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-09-17 11:24:56 -0700
committercolin <colin@cicadas.surf>2023-09-17 11:24:56 -0700
commit3a9aac9a7a1c59f6bdce5a26ea2d17bdf65921c9 (patch)
treef658a7c2b17a747bc14214c0d593225cdb741d91
parent10dfda16361f1feaaee64596abd3b3dcea25ebfa (diff)
Fixed response header setting to make redirection work
-rw-r--r--lazybones-hunchentoot.lisp11
-rw-r--r--lazybones.lisp1
2 files changed, 6 insertions, 6 deletions
diff --git a/lazybones-hunchentoot.lisp b/lazybones-hunchentoot.lisp
index 2ed078c..38480a0 100644
--- a/lazybones-hunchentoot.lisp
+++ b/lazybones-hunchentoot.lisp
@@ -280,18 +280,17 @@ the value of the Content-Type request header."
(when secure (list :secure secure))
(when http-only (list :http-only http-only)))))
-(defun http-respond (content &optional (code 200))
+(defun http-respond (content)
"Final step preparing response before backend does the rest. For
-Hunchentoot, set the response code and a few headers. If content is a
-pathname, pass off to HUNCHENTOOT:HANDLE-STATIC-FILE, otherwise just
-return the content."
+Hunchentoot set a few headers. If content is a pathname, pass off to
+HUNCHENTOOT:HANDLE-STATIC-FILE, otherwise just return the content."
;; When http-err is called, the content is likely to be null. If
;; that is the case, look for the default content for the error
;; code, and set content and content-type appropriately
(a:when-let (data
(and (null content)
- (canned-response %server% code)))
+ (canned-response %server% (response-code))))
(destructuring-bind (source content-type) data
(setf (response-header :content-type) content-type
content (if (or (functionp source) (symbolp source))
@@ -299,7 +298,7 @@ return the content."
source))))
;; set the response code and header.
- (setf (response-code) code
+ (setf
(response-header :content-type) (or (response-header :content-type)
(when (pathnamep content)
(h:mime-type content))
diff --git a/lazybones.lisp b/lazybones.lisp
index 9eb719a..0fe323b 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -339,6 +339,7 @@ applying HANDLER-FUNCTION slot of ENDPOINT to the ARGS list."
(let ((*request* request)
(*response* response)
(*app* app))
+ (setf (response-code) 200)
(if (request-authorized-p endpoint)
(http-respond (apply (endpoint-request-handler endpoint) args))
(http-err 403))))