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`
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
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