import qualified Data.ByteString.Char8 as C8 hiding (ByteString)
import Data.Dynamic
import Network.HTTP.Lucu.Format
+import Network.HTTP.Lucu.HandleLike
import Network.HTTP.Lucu.Headers
import Network.HTTP.Lucu.HttpVersion
-import System.IO
-- |This is the definition of HTTP status code.
-- 'Network.HTTP.Lucu.Resource.setStatus' accepts these named statuses
setHeaders res hdr = res { resHeaders = hdr }
-hPutResponse :: Handle -> Response -> IO ()
+hPutResponse :: HandleLike h => h -> Response -> IO ()
hPutResponse h res
= h `seq` res `seq`
do hPutHttpVersion h (resVersion res)
hPutChar h ' '
hPutStatus h (resStatus res)
- C8.hPut h (C8.pack "\r\n")
+ hPutBS h (C8.pack "\r\n")
hPutHeaders h (resHeaders res)
-hPutStatus :: Handle -> StatusCode -> IO ()
+hPutStatus :: HandleLike h => h -> StatusCode -> IO ()
hPutStatus h sc
= h `seq` sc `seq`
case statusCode sc of
(# num, msg #)
-> do hPutStr h (fmtDec 3 num)
hPutChar h ' '
- C8.hPut h msg
+ hPutBS h msg
-- |@'isInformational' sc@ is 'Prelude.True' iff @sc < 200@.