on master help sign in
Rename to requestHeaders, responseHeaders, responseBody
b4be853Michael Snoyman
Network/Wai.hs+5−4
@@ -355,10 +355,11 @@ data Request = Request
355 -- all information after the domain name. In a CGI application, this would be
355 -- all information after the domain name. In a CGI application, this would be
356 -- the information following the path to the CGI executable itself.
356 -- the information following the path to the CGI executable itself.
357 , pathInfo :: B.ByteString
357 , pathInfo :: B.ByteString
358+ -- | If no query string was specified, this should be empty.
358 , queryString :: B.ByteString
359 , queryString :: B.ByteString
359 , serverName :: B.ByteString
360 , serverName :: B.ByteString
360 , serverPort :: Int
361 , serverPort :: Int
361− , httpHeaders :: [(RequestHeader, B.ByteString)]
362+ , requestHeaders :: [(RequestHeader, B.ByteString)]
362 , urlScheme :: UrlScheme
363 , urlScheme :: UrlScheme
363 , requestBody :: forall a. Enumerator a
364 , requestBody :: forall a. Enumerator a
364 , errorHandler :: String -> IO ()
365 , errorHandler :: String -> IO ()
@@ -367,13 +368,13 @@ data Request = Request
367 }
368 }
368
369
369data Response = Response
370data Response = Response
370− { status :: Status
371+ { status :: Status
371− , headers :: [(ResponseHeader, B.ByteString)]
372+ , responseHeaders :: [(ResponseHeader, B.ByteString)]
372 -- | A common optimization is to use the sendfile system call when sending
373 -- | A common optimization is to use the sendfile system call when sending
373 -- files from the disk. This datatype facilitates this optimization; if
374 -- files from the disk. This datatype facilitates this optimization; if
374 -- 'Left' is returns, the server will send the file from the disk by whatever
375 -- 'Left' is returns, the server will send the file from the disk by whatever
375 -- means it wishes. If 'Right', it will call the 'Enumerator'.
376 -- 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)
377 }
378 }
378
379
379type Application = Request -> IO Response
380type Application = Request -> IO Response
Network/Wai/Enumerator.hs+1−1
@@ -69,7 +69,7 @@ fromLBS' lbs' iter a0 = lbs' >>= \lbs -> fromLBS lbs iter a0
69toSource :: Enumerator () -> IO (IO (Maybe B.ByteString))
69toSource :: Enumerator () -> IO (IO (Maybe B.ByteString))
70toSource e = do
70toSource e = do
71 buffer <- newEmptyMVar
71 buffer <- newEmptyMVar
72− forkIO $ e (helper buffer) () >> putMVar buffer Nothing
72+ _ <- forkIO $ e (helper buffer) () >> putMVar buffer Nothing
73 return $ source buffer
73 return $ source buffer
74 where
74 where
75 helper :: MVar (Maybe B.ByteString)
75 helper :: MVar (Maybe B.ByteString)
Network/Wai/Handler/SimpleServer.hs+3−3
@@ -127,7 +127,7 @@ parseRequest port lines' handle remoteHost' = do
127 , queryString = gets
127 , queryString = gets
128 , serverName = serverName'
128 , serverName = serverName'
129 , serverPort = port
129 , serverPort = port
130− , httpHeaders = heads
130+ , requestHeaders = heads
131 , urlScheme = HTTP
131 , urlScheme = HTTP
132 , requestBody = requestBodyHandle handle mlen
132 , requestBody = requestBodyHandle handle mlen
133 , errorHandler = System.IO.hPutStr System.IO.stderr
133 , errorHandler = System.IO.hPutStr System.IO.stderr
@@ -166,9 +166,9 @@ sendResponse h res = do
166 BS.hPut h $ SL.pack $ show $ statusCode $ status res
166 BS.hPut h $ SL.pack $ show $ statusCode $ status res
167 BS.hPut h $ statusMessage $ status res
167 BS.hPut h $ statusMessage $ status res
168 BS.hPut h $ SL.pack "\r\n"
168 BS.hPut h $ SL.pack "\r\n"
169− mapM_ putHeader $ headers res
169+ mapM_ putHeader $ responseHeaders res
170 BS.hPut h $ SL.pack "\r\n"
170 BS.hPut h $ SL.pack "\r\n"
171− case body res of
171+ case responseBody res of
172 Left fp -> unsafeSendFile h fp
172 Left fp -> unsafeSendFile h fp
173 Right enum -> enum myPut h >> return ()
173 Right enum -> enum myPut h >> return ()
174 where
174 where
test.hs+4−4
@@ -14,15 +14,15 @@ app req = case B8.unpack $ pathInfo req of
14indexResponse :: IO Response
14indexResponse :: IO Response
15indexResponse = return Response
15indexResponse = return Response
16 { status = Status200
16 { status = Status200
17− , headers = [(ContentType, B8.pack "text/html")]
17+ , responseHeaders = [(ContentType, B8.pack "text/html")]
18− , body = index
18+ , responseBody = index
19 }
19 }
20
20
21postResponse :: (forall a. Enumerator a) -> IO Response
21postResponse :: (forall a. Enumerator a) -> IO Response
22postResponse rb = return Response
22postResponse rb = return Response
23 { status = Status200
23 { status = Status200
24− , headers = [(ContentType, B8.pack "text/plain")]
24+ , responseHeaders = [(ContentType, B8.pack "text/plain")]
25− , body = Right rb
25+ , responseBody = Right rb
26 }
26 }
27
27
28index :: Either FilePath a
28index :: Either FilePath a