X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FResponseWriter.hs;h=63174b7cb5ea3d8f727c860d77efdea0710134dd;hp=3ab4bda714fc37295a3f2992e854e4179518e722;hb=73b5fba4907604681d778d3bd54cd65fd84b4454;hpb=c179f51aa7b15764807141c175f9fe8797424991 diff --git a/Network/HTTP/Lucu/ResponseWriter.hs b/Network/HTTP/Lucu/ResponseWriter.hs index 3ab4bda..63174b7 100644 --- a/Network/HTTP/Lucu/ResponseWriter.hs +++ b/Network/HTTP/Lucu/ResponseWriter.hs @@ -12,16 +12,17 @@ import qualified Data.Sequence as S import Data.Sequence (ViewR(..)) import Network.HTTP.Lucu.Config import Network.HTTP.Lucu.Format +import Network.HTTP.Lucu.HandleLike import Network.HTTP.Lucu.Headers import Network.HTTP.Lucu.HttpVersion import Network.HTTP.Lucu.Interaction import Network.HTTP.Lucu.Postprocess import Network.HTTP.Lucu.Response import Prelude hiding (catch) -import System.IO +import System.IO (stderr) -responseWriter :: Config -> Handle -> InteractionQueue -> ThreadId -> IO () +responseWriter :: HandleLike h => Config -> h -> InteractionQueue -> ThreadId -> IO () responseWriter !cnf !h !tQueue !readerTID = awaitSomethingToWrite `catches` @@ -135,11 +136,11 @@ responseWriter !cnf !h !tQueue !readerTID unless willDiscardBody $ do if willChunkBody then do hPutStr h (fmtHex False 0 $! fromIntegral $! C8.length chunk) - C8.hPut h (C8.pack "\r\n") - C8.hPut h chunk - C8.hPut h (C8.pack "\r\n") + hPutLBS h (C8.pack "\r\n") + hPutLBS h chunk + hPutLBS h (C8.pack "\r\n") else - C8.hPut h chunk + hPutLBS h chunk hFlush h awaitSomethingToWrite @@ -150,7 +151,7 @@ responseWriter !cnf !h !tQueue !readerTID do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id willChunkBody <- atomically $! readItr itr itrWillChunkBody id when (not willDiscardBody && willChunkBody) - $ C8.hPut h (C8.pack "0\r\n\r\n") >> hFlush h + $ hPutLBS h (C8.pack "0\r\n\r\n") >> hFlush h finalize :: Interaction -> IO () finalize itr