on master help sign in
Rename to requestHeaders, responseHeaders, responseBody
commitb4be853ddf9f12ca3bf7c717332a4983582e7ef8 authorMichael Snoyman <michael@snoyman.com> dateFri 5 Feb 2010, 17:54 (17 years ago) parent556030c
4 files changed+13−12
Network/Wai.hs+5−4 Network/Wai/Enumerator.hs+1−1 Network/Wai/Handler/SimpleServer.hs+3−3 test.hs+4−4
Network/Wai.hs+5−4
@@ -355,10 +355,11 @@ data Request = Request
355355 -- all information after the domain name. In a CGI application, this would be
356356 -- the information following the path to the CGI executable itself.
357357 , pathInfo :: B.ByteString
358+ -- | If no query string was specified, this should be empty.
358359 , queryString :: B.ByteString
359360 , serverName :: B.ByteString
360361 , serverPort :: Int
361− , httpHeaders :: [(RequestHeader, B.ByteString)]
362+ , requestHeaders :: [(RequestHeader, B.ByteString)]
362363 , urlScheme :: UrlScheme
363364 , requestBody :: forall a. Enumerator a
364365 , errorHandler :: String -> IO ()
@@ -367,13 +368,13 @@ data Request = Request
367368 }
368369
369370data Response = Response
370− { status :: Status
371− , headers :: [(ResponseHeader, B.ByteString)]
371+ { status :: Status
372+ , responseHeaders :: [(ResponseHeader, B.ByteString)]
372373 -- | A common optimization is to use the sendfile system call when sending
373374 -- files from the disk. This datatype facilitates this optimization; if
374375 -- 'Left' is returns, the server will send the file from the disk by whatever
375376 -- means it wishes. If 'Right', it will call the 'Enumerator'.
376− , body :: forall a. Either FilePath (Enumerator a)
377+ , responseBody :: forall a. Either FilePath (Enumerator a)
377378 }
378379
379380type Application = Request -> IO Response
Network/Wai/Enumerator.hs+1−1
@@ -69,7 +69,7 @@ fromLBS' lbs' iter a0 = lbs' >>= \lbs -> fromLBS lbs iter a0
6969toSource :: Enumerator () -> IO (IO (Maybe B.ByteString))
7070toSource e = do
7171 buffer <- newEmptyMVar
72− forkIO $ e (helper buffer) () >> putMVar buffer Nothing
72+ _ <- forkIO $ e (helper buffer) () >> putMVar buffer Nothing
7373 return $ source buffer
7474 where
7575 helper :: MVar (Maybe B.ByteString)
Network/Wai/Handler/SimpleServer.hs+3−3
@@ -127,7 +127,7 @@ parseRequest port lines' handle remoteHost' = do
127127 , queryString = gets
128128 , serverName = serverName'
129129 , serverPort = port
130− , httpHeaders = heads
130+ , requestHeaders = heads
131131 , urlScheme = HTTP
132132 , requestBody = requestBodyHandle handle mlen
133133 , errorHandler = System.IO.hPutStr System.IO.stderr
@@ -166,9 +166,9 @@ sendResponse h res = do
166166 BS.hPut h $ SL.pack $ show $ statusCode $ status res
167167 BS.hPut h $ statusMessage $ status res
168168 BS.hPut h $ SL.pack "\r\n"
169− mapM_ putHeader $ headers res
169+ mapM_ putHeader $ responseHeaders res
170170 BS.hPut h $ SL.pack "\r\n"
171− case body res of
171+ case responseBody res of
172172 Left fp -> unsafeSendFile h fp
173173 Right enum -> enum myPut h >> return ()
174174 where
test.hs+4−4
@@ -14,15 +14,15 @@ app req = case B8.unpack $ pathInfo req of
1414indexResponse :: IO Response
1515indexResponse = return Response
1616 { status = Status200
17− , headers = [(ContentType, B8.pack "text/html")]
18− , body = index
17+ , responseHeaders = [(ContentType, B8.pack "text/html")]
18+ , responseBody = index
1919 }
2020
2121postResponse :: (forall a. Enumerator a) -> IO Response
2222postResponse rb = return Response
2323 { status = Status200
24− , headers = [(ContentType, B8.pack "text/plain")]
25− , body = Right rb
24+ , responseHeaders = [(ContentType, B8.pack "text/plain")]
25+ , responseBody = Right rb
2626 }
2727
2828index :: Either FilePath a