50 lines
1.6 KiB
Scheme
50 lines
1.6 KiB
Scheme
;;;; Sending replies
|
|
;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;; Reply codes
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;; (define http-reply/ok 200), etc.
|
|
;;; Also, build an alist HTTP-REPLY-TEXT-TABLE mapping integer reply codes
|
|
;;; to their diagnostic text messages.
|
|
|
|
(define-syntax define-http-reply-codes
|
|
(syntax-rules ()
|
|
((define-http-reply-codes table set (name val msg) ...)
|
|
(begin (define table '((val . msg) ...))
|
|
(define-enum-constant set name val)
|
|
...))))
|
|
|
|
(define-http-reply-codes http-reply-text-table http-reply
|
|
(ok 200 "OK")
|
|
(created 201 "Created")
|
|
(accepted 202 "Accepted")
|
|
(prov-info 203 "Provisional Information")
|
|
(no-content 204 "No Content")
|
|
|
|
(mult-choice 300 "Multiple Choices")
|
|
(moved-perm 301 "Moved Permanently")
|
|
(moved-temp 302 "Moved Temporarily")
|
|
(method 303 "Method (obsolete)")
|
|
(not-mod 304 "Not Modified")
|
|
|
|
(bad-request 400 "Bad Request")
|
|
(unauthorized 401 "Unauthorized")
|
|
(payment-req 402 "Payment Required")
|
|
(forbidden 403 "Forbidden")
|
|
(not-found 404 "Not Found")
|
|
(method-not-allowed 405 "Method Not Allowed")
|
|
(none-acceptable 406 "None Acceptable")
|
|
(proxy-auth-required 407 "Proxy Authentication Required")
|
|
(timeout 408 "Request Timeout")
|
|
(conflict 409 "Conflict")
|
|
(gone 410 "Gone")
|
|
|
|
(internal-error 500 "Internal Server Error")
|
|
(not-implemented 501 "Not Implemented")
|
|
(bad-gateway 502 "Bad Gateway")
|
|
(service-unavailable 503 "Service Unavailable")
|
|
(gateway-timeout 504 "Gateway Timeout"))
|
|
|
|
(define (reply-code->text code)
|
|
(cdr (assv code http-reply-text-table)))
|