header keys can have a little lowercase

This commit is contained in:
Milo Turner 2020-04-10 19:41:20 -04:00
parent ce2976e37f
commit 2921a80b83
1 changed files with 6 additions and 6 deletions

View File

@ -90,14 +90,14 @@
;; ==========================================
(module+ test
(define ex-req-/ (make-http-req 'GET "/" '([Host . "localhost"])))
(define ex-req-/ (make-http-req 'GET "/" '([host . "localhost"])))
(define ex-res-ok (http-set-body (make-http-res 200) #"Hello world"))
(check-pred http-req? ex-req-/)
(check-pred http-res? ex-res-ok)
(check-equal? (hash-ref (http-msg-headers ex-req-/) 'Host) #"localhost")
(check-equal? (hash-ref (http-msg-headers ex-res-ok) 'Content-Length) #"11")
(check-equal? (hash-ref (http-msg-headers ex-req-/) 'host) #"localhost")
(check-equal? (hash-ref (http-msg-headers ex-res-ok) 'content-length) #"11")
(define-syntax-rule (check-http-msg->bytes msg bs ...)
(check-equal? (let ([p (open-output-bytes)])
@ -107,12 +107,12 @@
(check-http-msg->bytes ex-req-/
#"GET / HTTP/1.1\r\n"
#"Host: localhost\r\n"
#"host: localhost\r\n"
#"\r\n")
(check-http-msg->bytes ex-res-ok
#"HTTP/1.1 200 OK\r\n"
#"Content-Length: 11\r\n"
#"content-length: 11\r\n"
#"\r\n"
#"Hello world")
@ -132,7 +132,7 @@
(define (http-body-additional-headers bdy)
(match bdy
[#f '()]
[(? bytes? bs) `([Content-Length . ,(bytes-length bs)])]))
[(? bytes? bs) `([content-length . ,(bytes-length bs)])]))
(define (write-http-body bdy [port (current-output-port)])
(when bdy (write-bytes bdy port)))