@@ -115,7 +115,7 @@ import Data.List (foldl')
115115import Control.Monad (forever, when)
116116import qualified Network.HTTP.Types as H
117117import qualified Data.CaseInsensitive as CI
118−import System.IO (hPutStrLn, stderr)
118+import System.IO (hPrint, stderr)
119119import ReadInt (readInt64)
120120import qualified Data.IORef as I
121121import Data.String (IsString (..))
@@ -198,7 +198,7 @@ bindPort p s = do
198198 theBody addr =
199199 bracketOnError
200200 (Network.Socket.socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))
201− (sClose)
201+ sClose
202202 (\sock -> do
203203 setSocketOption sock ReuseAddr 1
204204 bindSocket sock (addrAddress addr)
@@ -511,6 +511,7 @@ sendResponse th req conn r = sendResponse' r
511511 needsChunked hs = isChunked' && not (hasLength hs)
512512 isKeepAlive hs = isPersist && (isChunked' || hasLength hs)
513513 hasLength hs = isJust $ lookup "content-length" hs
514+ sendHeader = connSendMany conn . L.toChunks . toLazyByteString
514515
515516 sendResponse' :: Response -> ResourceT IO Bool
516517 sendResponse' (ResponseFile s hs fp mpart) = liftIO $ do
@@ -523,8 +524,8 @@ sendResponse th req conn r = sendResponse' r
523524 (Nothing, Just part) -> do
524525 let cl = filePartByteCount part
525526 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
528529 T.tickle th
529530 if hasBody s req then do
530531 case mpart of
@@ -544,10 +545,7 @@ sendResponse th req conn r = sendResponse' r
544545 T.tickle th) body
545546 return (isKeepAlive hs)
546547 | otherwise = liftIO $ do
547− connSendMany conn
548− $ L.toChunks
549− $ toLazyByteString
550− $ headers' False
548+ sendHeader $ headers' False
551549 T.tickle th
552550 return isPersist
553551 where
@@ -566,9 +564,7 @@ sendResponse th req conn r = sendResponse' r
566564 src C.$$ builderToByteString C.=$ connSink conn th
567565 return $ isKeepAlive hs
568566 | otherwise = liftIO $ do
569− connSendMany conn
570− $ L.toChunks $ toLazyByteString
571− $ headers' False
567+ sendHeader $ headers' False
572568 T.tickle th
573569 return isPersist
574570 where
@@ -691,7 +687,7 @@ defaultSettings = Settings
691687 Just x -> go x
692688 Nothing ->
693689 when (go' $ fromException e) $
694− hPutStrLn stderr $ show e
690+ hPrint stderr e
695691 , settingsTimeout = 30
696692 , settingsIntercept = const Nothing
697693 , settingsManager = Nothing