diff --git a/scheme/httpd/core.scm b/scheme/httpd/core.scm index 4fcb31b..89f3794 100644 --- a/scheme/httpd/core.scm +++ b/scheme/httpd/core.scm @@ -153,7 +153,15 @@ #f ; No request yet. "Request parsing error -- report to client maintainer." (condition-stuff c)))) - (else + ((error? c) + ;; try to send bug report to client + (values #f + (apply make-http-error-response http-status/internal-error + #f ; don't know + (format #f + "Internal error occured while processing request") + c))) + (else ; there's no else... (decline)))) (lambda () (let ((initial-req (parse-http-request sock options))) @@ -320,13 +328,20 @@ (define (send-http-response request response input-port output-port options) - (if (not (v0.9-request? request)) - (send-http-headers response output-port)) + (if request + (begin + (if (not (v0.9-request? request)) + (send-http-headers response output-port)) - (if (not (string=? (request:method request) "HEAD")) - (display-http-body (response-body response) input-port output-port options)) + (if (not (string=? (request:method request) "HEAD")) + (display-http-body (response-body response) input-port output-port options)) - (http-log request (response-code response))) + (http-log request (response-code response))) + (begin + ;; We have a bad request error. Try to report this headerless. + (display-http-body (response-body response) input-port output-port options) + ;; no CLF-logging + ))) (define (send-http-header-fields headers port) (for-each (lambda (pair)