packages feed

simple-sendfile 0.2.0 → 0.2.1

raw patch · 3 files changed

+16/−24 lines, 3 filesdep +conduitdep −enumeratorPVP ok

version bump matches the API change (PVP)

Dependencies added: conduit

Dependencies removed: enumerator

API changes (from Hackage documentation)

Files

Network/Sendfile/Fallback.hs view
@@ -1,12 +1,9 @@ module Network.Sendfile.Fallback (sendfile) where -import Control.Monad import Control.Monad.IO.Class import Data.ByteString (ByteString)-import qualified Data.ByteString as BS-import Data.Enumerator-import Data.Enumerator.Binary as EB-import Data.Enumerator.List as EL+import Data.Conduit+import Data.Conduit.Binary as EB import Network.Sendfile.Types import Network.Socket import qualified Network.Socket.ByteString as SB@@ -18,21 +15,16 @@ -} sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO () sendfile s fp EntireFile hook =-    run_ $ enumFile fp $$ sendIter s hook+    runResourceT $ sourceFile fp $$ sinkSocket s hook sendfile s fp (PartOfFile off len) hook =-    run_ $ EB.enumFileRange fp (Just off) (Just len) $$ sendIter s hook--sendIter :: Socket -> IO () -> Iteratee ByteString IO ()-sendIter s hook = do-    mb <- EL.head-    case mb of-        Nothing -> return ()-        Just bs -> do-            liftIO $ sendLoop s bs (BS.length bs)-            liftIO hook -- FIXME: Is this a right place to call the hook?-            sendIter s hook+    runResourceT $ EB.sourceFileRange fp (Just off) (Just len) $$ sinkSocket s hook -sendLoop :: Socket -> ByteString -> Int -> IO ()-sendLoop s bs len = do-    bytes <- SB.send s bs-    when (bytes /= len) $ sendLoop s (BS.drop bytes bs) (len - bytes)+sinkSocket :: Socket -> IO () -> Sink ByteString IO ()+sinkSocket s hook =+    SinkData push close+  where+    push bs = do+        liftIO $ SB.sendAll s bs+        liftIO hook+        return (Processing push close)+    close = return ()
Network/Sendfile/Linux.hsc view
@@ -73,5 +73,5 @@           sendPart dst src offp left hook  -- Dst Src in order. take care-foreign import ccall unsafe "sendfile64" c_sendfile+foreign import ccall unsafe "sendfile" c_sendfile     :: Fd -> Fd -> Ptr (#type off_t) -> (#type size_t) -> IO (#type ssize_t)
simple-sendfile.cabal view
@@ -1,5 +1,5 @@ Name:                   simple-sendfile-Version:                0.2.0+Version:                0.2.1 Author:                 Kazu Yamamoto <kazu@iij.ad.jp> Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp> License:                BSD3@@ -37,7 +37,7 @@         Build-Depends: unix       else         Other-Modules: Network.Sendfile.Fallback-        Build-Depends: bytestring, enumerator, transformers+        Build-Depends: bytestring, conduit, transformers  Source-Repository head   Type:                 git