X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FResponseWriter.hs;h=266f825c4d8a0ce8e4d9190703d90dc050cc6a21;hp=f47e1f0fcb744dada3e486bd84c07bf469757880;hb=f812da5cfe314ab2a29f5e68aac1a7a7b39240d6;hpb=a9e9f50818285bf66cd64e5a248175eecb8e1fea diff --git a/Network/HTTP/Lucu/ResponseWriter.hs b/Network/HTTP/Lucu/ResponseWriter.hs index f47e1f0..266f825 100644 --- a/Network/HTTP/Lucu/ResponseWriter.hs +++ b/Network/HTTP/Lucu/ResponseWriter.hs @@ -15,13 +15,17 @@ import Network.HTTP.Lucu.Interaction import Network.HTTP.Lucu.Response import Prelude hiding (catch) import System.IO +import Text.Printf import Debug.Trace responseWriter :: Handle -> InteractionQueue -> IO () responseWriter h tQueue - = awaitSomethingToWrite + = catch awaitSomethingToWrite $ \ exc -> + case exc of + IOException _ -> return () + _ -> print exc where awaitSomethingToWrite :: IO () awaitSomethingToWrite @@ -104,14 +108,20 @@ responseWriter h tQueue return chunk unless willDiscardBody $ do if willChunkBody then - fail "FIXME: not implemented" + do hPrintf h "%x\r\n" (toInteger $ B.length chunk) + B.hPut h chunk + hPutStr h "\r\n" else B.hPut h chunk hFlush h awaitSomethingToWrite finishBodyChunk :: Interaction -> IO () - finishBodyChunk itr = return () -- FIXME: not implemented + finishBodyChunk itr + = do willDiscardBody <- atomically $ readItr itr itrWillDiscardBody id + willChunkBody <- atomically $ readItr itr itrWillChunkBody id + when (not willDiscardBody && willChunkBody) + $ hPutStr h "0\r\n" >> hFlush h finalize :: Interaction -> IO () finalize itr