Currently if a user want to define a custom http return code, s/he has to change reason-phrase function manually.
The attached patch file is my suggestion on this problem.
Cheers
Jong-won
diff -Naur hunchentoot-0.9.1/specials.lisp hunchentoot-new/specials.lisp --- hunchentoot-0.9.1/specials.lisp 2007-04-19 18:10:39.000000000 +0900 +++ hunchentoot-new/specials.lisp 2007-05-01 10:57:23.000000000 +0900 @@ -37,56 +37,59 @@ (defvar ,name) (setf (documentation ',name 'variable) ,doc-string)))
- (defmacro def-http-return-code (name value) + (defconstant +http-code-reason-table+ (make-hash-table :test #'eq)) + + (defmacro def-http-return-code (name value &optional (doc-string "One of the common HTTP return codes.")) "Shortcut to define constants for return codes." `(eval-when (:compile-toplevel :execute :load-toplevel) - (defconstant ,name ,value "One of the common HTTP return codes.")))) + (defconstant ,name ,value ,(format nil "HTTP return code for ~A" doc-string)) + (setf (gethash ,value +http-code-reason-table+) ,doc-string))))
(defconstant +crlf+ #.(format nil "~C~C" #\Return #\Linefeed) "A constant string consisting of the two ASCII characters CR and LF.")
-(def-http-return-code +http-continue+ 100) -(def-http-return-code +http-switching-protocols+ 101) -(def-http-return-code +http-ok+ 200) -(def-http-return-code +http-created+ 201) -(def-http-return-code +http-accepted+ 202) -(def-http-return-code +http-non-authoritative-information+ 203) -(def-http-return-code +http-no-content+ 204) -(def-http-return-code +http-reset-content+ 205) -(def-http-return-code +http-partial-content+ 206) -(def-http-return-code +http-multi-status+ 207) -(def-http-return-code +http-multiple-choices+ 300) -(def-http-return-code +http-moved-permanently+ 301) -(def-http-return-code +http-moved-temporarily+ 302) -(def-http-return-code +http-see-other+ 303) -(def-http-return-code +http-not-modified+ 304) -(def-http-return-code +http-use-proxy+ 305) -(def-http-return-code +http-temporary-redirect+ 307) -(def-http-return-code +http-bad-request+ 400) -(def-http-return-code +http-authorization-required+ 401) -(def-http-return-code +http-payment-required+ 402) -(def-http-return-code +http-forbidden+ 403) -(def-http-return-code +http-not-found+ 404) -(def-http-return-code +http-method-not-allowed+ 405) -(def-http-return-code +http-not-acceptable+ 406) -(def-http-return-code +http-proxy-authentication-required+ 407) -(def-http-return-code +http-request-time-out+ 408) -(def-http-return-code +http-conflict+ 409) -(def-http-return-code +http-gone+ 410) -(def-http-return-code +http-length-required+ 411) -(def-http-return-code +http-precondition-failed+ 412) -(def-http-return-code +http-request-entity-too-large+ 413) -(def-http-return-code +http-request-uri-too-large+ 414) -(def-http-return-code +http-unsupported-media-type+ 415) -(def-http-return-code +http-requested-range-not-satisfiable+ 416) -(def-http-return-code +http-expectation-failed+ 417) -(def-http-return-code +http-failed-dependency+ 424) -(def-http-return-code +http-internal-server-error+ 500) -(def-http-return-code +http-not-implemented+ 501) -(def-http-return-code +http-bad-gateway+ 502) -(def-http-return-code +http-service-unavailable+ 503) -(def-http-return-code +http-gateway-time-out+ 504) -(def-http-return-code +http-version-not-supported+ 505) +(def-http-return-code +http-continue+ 100 "Continue") +(def-http-return-code +http-switching-protocols+ 101 "Switching Protocols") +(def-http-return-code +http-ok+ 200 "OK") +(def-http-return-code +http-created+ 201 "Created") +(def-http-return-code +http-accepted+ 202 "Accepted") +(def-http-return-code +http-non-authoritative-information+ 203 "Non-Authoritative Information") +(def-http-return-code +http-no-content+ 204 "No Content") +(def-http-return-code +http-reset-content+ 205 "Reset Content") +(def-http-return-code +http-partial-content+ 206 "Partial Content") +(def-http-return-code +http-multi-status+ 207 "Multi-Status") +(def-http-return-code +http-multiple-choices+ 300 "Multiple Choices") +(def-http-return-code +http-moved-permanently+ 301 "Moved Permanently") +(def-http-return-code +http-moved-temporarily+ 302 "Moved Temporarily") +(def-http-return-code +http-see-other+ 303 "See Other") +(def-http-return-code +http-not-modified+ 304 "Not Modified") +(def-http-return-code +http-use-proxy+ 305 "Use Proxy") +(def-http-return-code +http-temporary-redirect+ 307 "Temporary Redirect") +(def-http-return-code +http-bad-request+ 400 "Bad Request") +(def-http-return-code +http-authorization-required+ 401 "Authorization Required") +(def-http-return-code +http-payment-required+ 402 "Payment Required") +(def-http-return-code +http-forbidden+ 403 "Forbidden") +(def-http-return-code +http-not-found+ 404 "Not Found") +(def-http-return-code +http-method-not-allowed+ 405 "Method Not Allowed") +(def-http-return-code +http-not-acceptable+ 406 "Not Acceptable") +(def-http-return-code +http-proxy-authentication-required+ 407 "Proxy Authentication Required") +(def-http-return-code +http-request-time-out+ 408 "Request Time-out") +(def-http-return-code +http-conflict+ 409 "Conflict") +(def-http-return-code +http-gone+ 410 "Gone") +(def-http-return-code +http-length-required+ 411 "Length Required") +(def-http-return-code +http-precondition-failed+ 412 "Precondition Failed") +(def-http-return-code +http-request-entity-too-large+ 413 "Request Entity Too Large") +(def-http-return-code +http-request-uri-too-large+ 414 "Request-URI Too Large") +(def-http-return-code +http-unsupported-media-type+ 415 "Unsupported Media Type") +(def-http-return-code +http-requested-range-not-satisfiable+ 416 "Requested range not satisfiable") +(def-http-return-code +http-expectation-failed+ 417 "Expectation Failed") +(def-http-return-code +http-failed-dependency+ 424 "Failed Dependency") +(def-http-return-code +http-internal-server-error+ 500 "Internal Server Error") +(def-http-return-code +http-not-implemented+ 501 "Not Implemented") +(def-http-return-code +http-bad-gateway+ 502 "Bad Gateway") +(def-http-return-code +http-service-unavailable+ 503 "Service Unavailable") +(def-http-return-code +http-gateway-time-out+ 504 "Gateway Time-out") +(def-http-return-code +http-version-not-supported+ 505 "Version not supported")
(defvar *approved-return-codes* '(#.+http-ok+ #.+http-no-content+ #.+http-multi-status+ diff -Naur hunchentoot-0.9.1/util.lisp hunchentoot-new/util.lisp --- hunchentoot-0.9.1/util.lisp 2007-04-04 16:52:06.000000000 +0900 +++ hunchentoot-new/util.lisp 2007-05-01 10:58:18.000000000 +0900 @@ -154,48 +154,7 @@ "Returns a reason phrase for the HTTP return code RETURN-CODE (which should be an integer) or NIL for return codes Hunchentoot doesn't know." - (case return-code - ((#.+http-ok+) "OK") - ((#.+http-moved-permanently+) "Moved Permanently") - ((#.+http-moved-temporarily+) "Moved Temporarily") - ((#.+http-not-modified+) "Not Modified") - ((#.+http-authorization-required+) "Authorization Required") - ((#.+http-forbidden+) "Forbidden") - ((#.+http-not-found+) "Not Found") - ((#.+http-internal-server-error+) "Internal Server Error") - ((#.+http-continue+) "Continue") - ((#.+http-switching-protocols+) "Switching Protocols") - ((#.+http-created+) "Created") - ((#.+http-accepted+) "Accepted") - ((#.+http-non-authoritative-information+) "Non-Authoritative Information") - ((#.+http-no-content+) "No Content") - ((#.+http-reset-content+) "Reset Content") - ((#.+http-partial-content+) "Partial Content") - ((#.+http-multi-status+) "Multi-Status") - ((#.+http-multiple-choices+) "Multiple Choices") - ((#.+http-see-other+) "See Other") - ((#.+http-use-proxy+) "Use Proxy") - ((#.+http-temporary-redirect+) "Temporary Redirect") - ((#.+http-bad-request+) "Bad Request") - ((#.+http-payment-required+) "Payment Required") - ((#.+http-method-not-allowed+) "Method Not Allowed") - ((#.+http-not-acceptable+) "Not Acceptable") - ((#.+http-proxy-authentication-required+) "Proxy Authentication Required") - ((#.+http-request-time-out+) "Request Time-out") - ((#.+http-conflict+) "Conflict") - ((#.+http-gone+) "Gone") - ((#.+http-length-required+) "Length Required") - ((#.+http-precondition-failed+) "Precondition Failed") - ((#.+http-request-entity-too-large+) "Request Entity Too Large") - ((#.+http-request-uri-too-large+) "Request-URI Too Large") - ((#.+http-unsupported-media-type+) "Unsupported Media Type") - ((#.+http-requested-range-not-satisfiable+) "Requested range not satisfiable") - ((#.+http-expectation-failed+) "Expectation Failed") - ((#.+http-not-implemented+) "Not Implemented") - ((#.+http-bad-gateway+) "Bad Gateway") - ((#.+http-service-unavailable+) "Service Unavailable") - ((#.+http-gateway-time-out+) "Gateway Time-out") - ((#.+http-version-not-supported+) "Version not supported"))) + (gethash return-code +http-code-reason-table+ nil))
(defun make-keyword (string &key (destructivep t)) "Interns the upcased version of STRING into the KEYWORD package.