on master help sign in
Using sendfileWithHeader.
commitbc5e13d6f2bde37d5b3696210a733cdb06bb913b authorKazu Yamamoto <kazu@iij.ad.jp> dateThu 21 Jun 2012, 16:17 (14 years ago) parentb448ef8
2 files changed+6−7
warp/Network/Wai/Handler/Warp.hs+5−6 warp/warp.cabal+1−1
warp/Network/Wai/Handler/Warp.hs+5−6
@@ -162,7 +162,7 @@ allowInterrupt = unblock $ return ()
162162data Connection = Connection
163163 { connSendMany :: [B.ByteString] -> IO ()
164164 , connSendAll :: B.ByteString -> IO ()
165− , connSendFile :: FilePath -> Integer -> Integer -> IO () -> IO () -- ^ offset, length
165+ , connSendFile :: FilePath -> Integer -> Integer -> IO () -> [ByteString] -> IO () -- ^ offset, length
166166 , connClose :: IO ()
167167 , connRecv :: IO B.ByteString
168168 }
@@ -171,7 +171,7 @@ socketConnection :: Socket -> Connection
171171socketConnection s = Connection
172172 { connSendMany = Sock.sendMany s
173173 , connSendAll = Sock.sendAll s
174− , connSendFile = \fp off len act -> sendfile s fp (PartOfFile off len) act
174+ , connSendFile = \fp off len act hdr -> sendfileWithHeader s fp (PartOfFile off len) act hdr
175175 , connClose = sClose s
176176 , connRecv = Sock.recv s bytesPerRead
177177 }
@@ -586,13 +586,12 @@ sendResponse th req conn r = sendResponse' r
586586 [("Content-Type", "text/plain")]
587587 "File not found"
588588 Right (lengthyHeaders, cl) -> liftIO $ do
589− let headers' = headers version s lengthyHeaders
590− sendHeader $ headers' False
589+ let headers' = L.toChunks . toLazyByteString $ headers version s lengthyHeaders False
591590 T.tickle th
592591 if hasBody s req then do
593592 case mpart of
594− Nothing -> connSendFile conn fp 0 cl (T.tickle th)
595− Just part -> connSendFile conn fp (filePartOffset part) (filePartByteCount part) (T.tickle th)
593+ Nothing -> connSendFile conn fp 0 cl (T.tickle th) headers'
594+ Just part -> connSendFile conn fp (filePartOffset part) (filePartByteCount part) (T.tickle th) headers'
596595 T.tickle th
597596 return isPersist
598597 else
warp/warp.cabal+1−1
@@ -26,7 +26,7 @@ Library
2626 , blaze-builder-conduit >= 0.4 && < 0.5
2727 , lifted-base >= 0.1 && < 0.2
2828 , blaze-builder >= 0.2.1.4 && < 0.4
29− , simple-sendfile >= 0.2.2 && < 0.3
29+ , simple-sendfile >= 0.2.4 && < 0.3
3030 , http-types >= 0.6 && < 0.7
3131 , case-insensitive >= 0.2
3232 , unix-compat >= 0.2