Hostnames are case-insensitive
svn: r6648
This commit is contained in:
parent
36063c4a5c
commit
e86b8c99cc
|
@ -3,6 +3,7 @@
|
||||||
(lib "plt-match.ss")
|
(lib "plt-match.ss")
|
||||||
(lib "url.ss" "net")
|
(lib "url.ss" "net")
|
||||||
"../private/request-structs.ss"
|
"../private/request-structs.ss"
|
||||||
|
"../private/util.ss"
|
||||||
"dispatch.ss")
|
"dispatch.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version?]
|
||||||
|
@ -14,12 +15,12 @@
|
||||||
((lookup-dispatcher host) conn req))
|
((lookup-dispatcher host) conn req))
|
||||||
|
|
||||||
;; get-host : Url (listof (cons Symbol String)) -> Symbol
|
;; get-host : Url (listof (cons Symbol String)) -> Symbol
|
||||||
;; XXX host names are case insesitive---Internet RFC 1034
|
|
||||||
(define (get-host uri headers)
|
(define (get-host uri headers)
|
||||||
(cond
|
(cond
|
||||||
[(url-host uri) => string->symbol]
|
[(url-host uri)
|
||||||
|
=> lowercase-symbol!]
|
||||||
[(headers-assq* #"Host" headers)
|
[(headers-assq* #"Host" headers)
|
||||||
=> (match-lambda
|
=> (match-lambda
|
||||||
[(struct header (_ v))
|
[(struct header (_ v))
|
||||||
(string->symbol (bytes->string/utf-8 v))])]
|
(lowercase-symbol! v)])]
|
||||||
[else '<none>])))
|
[else 'none])))
|
|
@ -225,7 +225,7 @@ that calls a different dispatcher based upon the host requested.
|
||||||
dispatcher?]{
|
dispatcher?]{
|
||||||
Extracts a host from the URL requested, or the Host HTTP header,
|
Extracts a host from the URL requested, or the Host HTTP header,
|
||||||
calls @scheme[lookup-dispatcher] with the host, and invokes the
|
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.
|
is used.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user