@@ -31,8 +31,7 @@ import Data.ByteString.Lazy.Internal (defaultChunkSize)
3131import System.IO (Handle)
3232import Network.HTTP.Types (Status (..))
3333import qualified Network.HTTP.Types as H
34−import Data.Ascii (ciToByteString)
35−import qualified Data.Ascii as A
34+import qualified Data.CaseInsensitive as CI
3635
3736safeRead :: Read a => a -> String -> a
3837safeRead d s =
@@ -98,14 +97,14 @@ run'' vars inputH outputH xsendfile app = do
9897 a:_ -> addrAddress a
9998 [] -> error $ "Invalid REMOTE_ADDR or REMOTE_HOST: " ++ remoteHost'
10099 let env = Request
101− { requestMethod = A.unsafeFromByteString rmethod
100+ { requestMethod = rmethod
102101 , rawPathInfo = B.pack pinfo
103102 , pathInfo = H.decodePathSegments $ B.pack pinfo
104103 , rawQueryString = B.pack qstring
105104 , queryString = H.parseQuery $ B.pack qstring
106105 , serverName = B.pack servername
107106 , serverPort = serverport
108− , requestHeaders = map (cleanupVarName *** A.unsafeFromString) vars
107+ , requestHeaders = map (cleanupVarName *** B.pack) vars
109108 , isSecure = isSecure'
110109 , errorHandler = System.IO.hPutStr System.IO.stderr
111110 , remoteHost = addr
@@ -114,7 +113,7 @@ run'' vars inputH outputH xsendfile app = do
114113 -- FIXME worry about exception?
115114 res <- run_ $ inputH contentLength $$ app env
116115 case (xsendfile, res) of
117− (Just sf, ResponseFile s hs fp) ->
116+ (Just sf, ResponseFile s hs fp Nothing) ->
118117 mapM_ outputH $ L.toChunks $ toLazyByteString $ sfBuilder s hs sf fp
119118 _ -> responseEnumerator res $ \s hs ->
120119 joinI $ enumList 1 [headers s hs, fromChar '\n'] $$ builderIter
@@ -123,9 +122,9 @@ run'' vars inputH outputH xsendfile app = do
123122 status (Status i m) = (fromByteString "Status", mconcat
124123 [ fromString $ show i
125124 , fromChar ' '
126− , fromByteString $ A.toByteString m
125+ , fromByteString m
127126 ])
128− header' (x, y) = (fromByteString $ ciToByteString x, fromByteString $ A.toByteString y)
127+ header' (x, y) = (fromByteString $ CI.original x, fromByteString y)
129128 header (x, y) = mconcat
130129 [ x
131130 , fromByteString ": "
@@ -149,7 +148,7 @@ run'' vars inputH outputH xsendfile app = do
149148 Nothing -> ("Content-Type", "text/html; charset=utf-8") : h
150149 Just _ -> h
151150
152−cleanupVarName :: String -> A.CIAscii
151+cleanupVarName :: String -> CI.CI B.ByteString
153152cleanupVarName ('H':'T':'T':'P':'_':a:as) =
154153 String.fromString $ a : helper' as
155154 where