answer HTTP/1.0 for requests with unknown HTTP-version
This commit is contained in:
parent
7090147e49
commit
96216b243d
|
@ -20,6 +20,7 @@
|
||||||
;;; The RFC detailing the HTTP 1.0 protocol, RFC 1945, can be found at
|
;;; The RFC detailing the HTTP 1.0 protocol, RFC 1945, can be found at
|
||||||
;;; http://www.w3.org/Protocols/rfc1945/rfc1945
|
;;; http://www.w3.org/Protocols/rfc1945/rfc1945
|
||||||
|
|
||||||
|
|
||||||
(define server/protocol "HTTP/1.0")
|
(define server/protocol "HTTP/1.0")
|
||||||
|
|
||||||
(define (httpd options)
|
(define (httpd options)
|
||||||
|
@ -247,15 +248,14 @@
|
||||||
(version (case (length elts)
|
(version (case (length elts)
|
||||||
((2) '(0 . 9))
|
((2) '(0 . 9))
|
||||||
((3) (parse-http-version (caddr elts)))
|
((3) (parse-http-version (caddr elts)))
|
||||||
(else (fatal-syntax-error "Bad HTTP version.")))))
|
(else (fatal-syntax-error "Bad Request Line."))))
|
||||||
|
(meth (car elts))
|
||||||
(let* ((meth (car elts))
|
|
||||||
(uri-string (cadr elts))
|
(uri-string (cadr elts))
|
||||||
(url (parse-http-servers-url-fragment uri-string sock options))
|
(url (parse-http-servers-url-fragment uri-string sock options))
|
||||||
(headers (if (equal? version '(0 . 9))
|
(headers (if (equal? version '(0 . 9))
|
||||||
'()
|
'()
|
||||||
(read-rfc822-headers (socket:inport sock)))))
|
(read-rfc822-headers (socket:inport sock)))))
|
||||||
(make-request meth uri-string url version headers sock))))))
|
(make-request meth uri-string url version headers sock)))))
|
||||||
|
|
||||||
;;; Parse the URL, but if it begins without the "http://host:port"
|
;;; Parse the URL, but if it begins without the "http://host:port"
|
||||||
;;; prefix, interpolate one from SOCKET. It would be sleazier but
|
;;; prefix, interpolate one from SOCKET. It would be sleazier but
|
||||||
|
@ -340,23 +340,26 @@
|
||||||
|
|
||||||
(write-crlf port))
|
(write-crlf port))
|
||||||
|
|
||||||
|
|
||||||
(define (send-http-response request response input-port output-port options)
|
(define (send-http-response request response input-port output-port options)
|
||||||
(cond
|
(cond
|
||||||
|
;;if request-record could not be built (i.e. either
|
||||||
|
;;fatal-syntax-error was called because of an erroneous request
|
||||||
|
;;line, or an server-internal error (not an os-error) occurred)
|
||||||
|
;;and therefore HTTP-version of request is not known, answer
|
||||||
|
;;with HTTP/1.0
|
||||||
((not request)
|
((not request)
|
||||||
;; We have a bad request error. Try to report this headerless.
|
(send-http-headers response output-port)
|
||||||
(display-http-body (response-body response) input-port output-port options)
|
(display-http-body (response-body response) input-port output-port options))
|
||||||
;; no CLF-logging
|
;;no CLF-logging)
|
||||||
)
|
|
||||||
((nph-response? response)
|
((nph-response? response)
|
||||||
(display-http-body (nph-response-body response) input-port output-port options)
|
(display-http-body (nph-response-body response) input-port output-port options)
|
||||||
(http-log request (status-code ok))); guess the status code
|
(http-log request (status-code ok))); guess the status code
|
||||||
(else
|
(else
|
||||||
(if (not (v0.9-request? request))
|
(if (not (v0.9-request? request))
|
||||||
(send-http-headers response output-port))
|
(send-http-headers response output-port))
|
||||||
|
|
||||||
(if (not (string=? (request-method request) "HEAD"))
|
(if (not (string=? (request-method request) "HEAD"))
|
||||||
(display-http-body (response-body response) input-port output-port options))
|
(display-http-body (response-body response) input-port output-port options))
|
||||||
|
|
||||||
(http-log request (response-code response)))))
|
(http-log request (response-code response)))))
|
||||||
|
|
||||||
(define (send-http-header-fields headers port)
|
(define (send-http-header-fields headers port)
|
||||||
|
|
Loading…
Reference in New Issue