Hostnames are case-insensitive

svn: r6648
This commit is contained in:
Jay McCarthy 2007-06-13 21:22:10 +00:00
parent 36063c4a5c
commit e86b8c99cc
2 changed files with 6 additions and 5 deletions

View File

@ -3,6 +3,7 @@
(lib "plt-match.ss")
(lib "url.ss" "net")
"../private/request-structs.ss"
"../private/util.ss"
"dispatch.ss")
(provide/contract
[interface-version dispatcher-interface-version?]
@ -14,12 +15,12 @@
((lookup-dispatcher host) conn req))
;; get-host : Url (listof (cons Symbol String)) -> Symbol
;; XXX host names are case insesitive---Internet RFC 1034
(define (get-host uri headers)
(cond
[(url-host uri) => string->symbol]
[(url-host uri)
=> lowercase-symbol!]
[(headers-assq* #"Host" headers)
=> (match-lambda
[(struct header (_ v))
(string->symbol (bytes->string/utf-8 v))])]
[else '<none>])))
(lowercase-symbol! v)])]
[else 'none])))

View File

@ -225,7 +225,7 @@ that calls a different dispatcher based upon the host requested.
dispatcher?]{
Extracts a host from the URL requested, or the Host HTTP header,
calls @scheme[lookup-dispatcher] with the host, and invokes the
returned dispatcher. If no host can be extracted, then @scheme['<none>]
returned dispatcher. If no host can be extracted, then @scheme['none]
is used.
}