on master help sign in
cosmetic change according to hlint.
72a24d3Kazu Yamamoto
warp/Network/Wai/Handler/Warp.hs+8−12
@@ -115,7 +115,7 @@ import Data.List (foldl')
115import Control.Monad (forever, when)
115import Control.Monad (forever, when)
116import qualified Network.HTTP.Types as H
116import qualified Network.HTTP.Types as H
117import qualified Data.CaseInsensitive as CI
117import qualified Data.CaseInsensitive as CI
118−import System.IO (hPutStrLn, stderr)
118+import System.IO (hPrint, stderr)
119import ReadInt (readInt64)
119import ReadInt (readInt64)
120import qualified Data.IORef as I
120import qualified Data.IORef as I
121import Data.String (IsString (..))
121import Data.String (IsString (..))
@@ -198,7 +198,7 @@ bindPort p s = do
198 theBody addr =
198 theBody addr =
199 bracketOnError
199 bracketOnError
200 (Network.Socket.socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))
200 (Network.Socket.socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))
201− (sClose)
201+ sClose
202 (\sock -> do
202 (\sock -> do
203 setSocketOption sock ReuseAddr 1
203 setSocketOption sock ReuseAddr 1
204 bindSocket sock (addrAddress addr)
204 bindSocket sock (addrAddress addr)
@@ -511,6 +511,7 @@ sendResponse th req conn r = sendResponse' r
511 needsChunked hs = isChunked' && not (hasLength hs)
511 needsChunked hs = isChunked' && not (hasLength hs)
512 isKeepAlive hs = isPersist && (isChunked' || hasLength hs)
512 isKeepAlive hs = isPersist && (isChunked' || hasLength hs)
513 hasLength hs = isJust $ lookup "content-length" hs
513 hasLength hs = isJust $ lookup "content-length" hs
514+ sendHeader = connSendMany conn . L.toChunks . toLazyByteString
514
515
515 sendResponse' :: Response -> ResourceT IO Bool
516 sendResponse' :: Response -> ResourceT IO Bool
516 sendResponse' (ResponseFile s hs fp mpart) = liftIO $ do
517 sendResponse' (ResponseFile s hs fp mpart) = liftIO $ do
@@ -523,8 +524,8 @@ sendResponse th req conn r = sendResponse' r
523 (Nothing, Just part) -> do
524 (Nothing, Just part) -> do
524 let cl = filePartByteCount part
525 let cl = filePartByteCount part
525 return $ addClToHeaders cl
526 return $ addClToHeaders cl
526− connSendMany conn $ L.toChunks $ toLazyByteString $
527− headers version s lengthyHeaders False
527+ let headers' = headers version s lengthyHeaders
528+ sendHeader $ headers' False
528 T.tickle th
529 T.tickle th
529 if hasBody s req then do
530 if hasBody s req then do
530 case mpart of
531 case mpart of
@@ -544,10 +545,7 @@ sendResponse th req conn r = sendResponse' r
544 T.tickle th) body
545 T.tickle th) body
545 return (isKeepAlive hs)
546 return (isKeepAlive hs)
546 | otherwise = liftIO $ do
547 | otherwise = liftIO $ do
547− connSendMany conn
548− $ L.toChunks
549− $ toLazyByteString
550− $ headers' False
548+ sendHeader $ headers' False
551 T.tickle th
549 T.tickle th
552 return isPersist
550 return isPersist
553 where
551 where
@@ -566,9 +564,7 @@ sendResponse th req conn r = sendResponse' r
566 src C.$$ builderToByteString C.=$ connSink conn th
564 src C.$$ builderToByteString C.=$ connSink conn th
567 return $ isKeepAlive hs
565 return $ isKeepAlive hs
568 | otherwise = liftIO $ do
566 | otherwise = liftIO $ do
569− connSendMany conn
570− $ L.toChunks $ toLazyByteString
571− $ headers' False
567+ sendHeader $ headers' False
572 T.tickle th
568 T.tickle th
573 return isPersist
569 return isPersist
574 where
570 where
@@ -691,7 +687,7 @@ defaultSettings = Settings
691 Just x -> go x
687 Just x -> go x
692 Nothing ->
688 Nothing ->
693 when (go' $ fromException e) $
689 when (go' $ fromException e) $
694− hPutStrLn stderr $ show e
690+ hPrint stderr e
695 , settingsTimeout = 30
691 , settingsTimeout = 30
696 , settingsIntercept = const Nothing
692 , settingsIntercept = const Nothing
697 , settingsManager = Nothing
693 , settingsManager = Nothing