From ef7a21b729b5330f9e328858984b6724e2eef9b9 Mon Sep 17 00:00:00 2001 From: sperber Date: Mon, 20 Jan 2003 16:24:29 +0000 Subject: [PATCH] - make MAKE-PATH-PREFIX-HANDLER work right for null paths. - add our own version of GET-HEADER in preparation for the RFC822 overhaul --- scheme/httpd/handlers.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scheme/httpd/handlers.scm b/scheme/httpd/handlers.scm index 0b29ac9..81bdeaa 100644 --- a/scheme/httpd/handlers.scm +++ b/scheme/httpd/handlers.scm @@ -51,11 +51,20 @@ (string=? hostname (string-trim (get-header (request-headers req) 'host)))) handler default-handler)) +(define (get-header headers tag) + (cond + ((assq tag headers) => cdr) + (else + (http-error (status-code bad-request) #f + (string-append "Request did not contain " + (symbol->string tag) + " header"))))) + ;; selects handler according to path-prefix ;; if path-prefix matches, handler is called without the path-prefix (define (make-path-prefix-handler path-prefix handler default-handler) (lambda (path req) - (if (string=? path-prefix (car path)) + (if (and (pair? path) (string=? path-prefix (car path))) (handler (cdr path) req) (default-handler path req))))