on master help sign in
Set serverName and port even if HTTP/1.0 is used.

Noe that HTTP/1.0 does not define Host: header.

commit6f8fa02e6261b586c15f4e450132925486a8c2b2 authorKazu Yamamoto <kazu@iij.ad.jp> dateTue 1 Mar 2011, 16:30 (16 years ago) parent2f45a71
1 file changed+6−4
Network/Wai/Handler/Warp.hs+6−4
Network/Wai/Handler/Warp.hs+6−4
@@ -207,12 +207,14 @@ parseRequest' :: Port
207207parseRequest' _ [] _ = E.throwError $ NotEnoughLines []
208208parseRequest' port (firstLine:otherLines) remoteHost' = do
209209 (method, rpath', gets, httpversion) <- parseFirst firstLine
210− let rpath =
210+ let (host',rpath) =
211211 if S.null rpath'
212− then "/"
213− else rpath'
212+ then ("","/")
213+ else if "http://" `S.isPrefixOf` rpath'
214+ then S.break (47==) $ S.drop 7 rpath' -- '/'
215+ else ("", rpath')
214216 let heads = map parseHeaderNoAttr otherLines
215− let host = fromMaybe "" $ lookup "host" heads
217+ let host = fromMaybe host' $ lookup "host" heads
216218 let len =
217219 case lookup "content-length" heads of
218220 Nothing -> 0