From 3a9aac9a7a1c59f6bdce5a26ea2d17bdf65921c9 Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 17 Sep 2023 11:24:56 -0700 Subject: Fixed response header setting to make redirection work --- lazybones-hunchentoot.lisp | 11 +++++------ lazybones.lisp | 1 + 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)))) -- cgit v1.2.3