+catch calls of make-error-response with too few arguments
This commit is contained in:
parent
4b37826de8
commit
a3dd880c7a
|
@ -146,14 +146,18 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; As a special case, request REQ is allowed to be #f, meaning we haven't
|
||||
;;; even had a chance to parse and construct the request. This is only used
|
||||
;;; for 400 BAD-REQUEST error report.
|
||||
|
||||
;;; even had a chance to parse and construct the request. This can be the case for
|
||||
;;; internal-error, bad-request, (possibly bad-gateway and ...?)
|
||||
|
||||
|
||||
(define (make-error-response code req . extras)
|
||||
(let*
|
||||
((generic-title (lambda (port)
|
||||
(let*
|
||||
;;catch server internal errors coming off by calls of make-error-response with too few arguments
|
||||
((assert (lambda (n)
|
||||
(if (< (length extras) n)
|
||||
(make-error-response (status-code internal-error) req
|
||||
"Too few arguments to make-error-response"))))
|
||||
(generic-title (lambda (port)
|
||||
(title-html port
|
||||
(status-code-message code))))
|
||||
(close-html (lambda (port args)
|
||||
|
@ -179,6 +183,7 @@
|
|||
(eq? code (status-code see-other));303
|
||||
(eq? code (status-code temp-redirect));307
|
||||
(eq? code (status-code moved-perm)));301
|
||||
(assert 1)
|
||||
(create-response
|
||||
(list (cons 'location (car extras)))
|
||||
(lambda (port options)
|
||||
|
@ -204,6 +209,7 @@
|
|||
;; the second one is the value of the Allow field header,
|
||||
;; which must be a list of valid methods for the requested resource
|
||||
((eq? code (status-code method-not-allowed))
|
||||
(assert 2)
|
||||
(create-response
|
||||
(list (cons 'allow (cadr extras)))
|
||||
(lambda (port options)
|
||||
|
@ -215,6 +221,7 @@
|
|||
;; the value of the WWW-Authenticate header field,
|
||||
;; which must be a challenge (as described in RFC 2617)
|
||||
((eq? code (status-code unauthorized))
|
||||
(assert 1)
|
||||
(create-response
|
||||
(list (cons 'WWW-Authenticate (car extras)))
|
||||
(lambda (port options)
|
||||
|
@ -251,6 +258,7 @@
|
|||
;; This error response requires one arg:
|
||||
;; the unimplemented method
|
||||
((eq? code (status-code not-implemented))
|
||||
(assert 1)
|
||||
(create-response
|
||||
'()
|
||||
(lambda (port options)
|
||||
|
|
Loading…
Reference in New Issue