simple-sendfile 0.2.30 → 0.2.31
raw patch · 5 files changed
+98/−84 lines, 5 files
Files
- Network/Sendfile/BSD.hsc +4/−4
- Network/Sendfile/Fallback.hs +3/−4
- Network/Sendfile/Linux.hsc +4/−4
- System/Linux/Sendfile.hs +2/−2
- simple-sendfile.cabal +85/−70
Network/Sendfile/BSD.hsc view
@@ -42,7 +42,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO () sendfile sock path range hook = bracket setup teardown $ \fd ->@@ -59,7 +59,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileFd :: Socket -> Fd -> FileRange -> IO () -> IO () sendfileFd sock fd range hook = do@@ -109,7 +109,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO () sendfileWithHeader sock path range hook hdr =@@ -131,7 +131,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileFdWithHeader :: Socket -> Fd -> FileRange -> IO () -> [ByteString] -> IO () sendfileFdWithHeader sock fd range hook hdr = do
Network/Sendfile/Fallback.hs view
@@ -12,7 +12,6 @@ import Network.Socket import Network.Socket.ByteString import qualified Network.Socket.ByteString as SB-import Control.Monad.Trans.Resource (runResourceT) -- | -- Sendfile emulation using conduit.@@ -22,12 +21,12 @@ sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO () sendfile sock path EntireFile hook =- runResourceT $ sourceFile path $$ sinkSocket sock hook+ runConduitRes $ sourceFile path .| sinkSocket sock hook sendfile sock path (PartOfFile off len) hook =- runResourceT $ EB.sourceFileRange path (Just off) (Just len) $$ sinkSocket sock hook+ runConduitRes $ EB.sourceFileRange path (Just off) (Just len) .| sinkSocket sock hook -- See sinkHandle.-sinkSocket :: MonadIO m => Socket -> IO () -> Sink ByteString m ()+sinkSocket :: MonadIO m => Socket -> IO () -> ConduitT ByteString Void m () #if MIN_VERSION_conduit(0,5,0) sinkSocket s hook = awaitForever $ \bs -> liftIO $ SB.sendAll s bs >> hook #else
Network/Sendfile/Linux.hsc view
@@ -61,7 +61,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO () sendfile sock path range hook = bracket setup teardown $ \fd ->@@ -91,7 +91,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileFd :: Socket -> Fd -> FileRange -> IO () -> IO () sendfileFd sock fd range hook = do #if MIN_VERSION_network(3,1,0)@@ -172,7 +172,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO () sendfileWithHeader sock path range hook hdr = do@@ -198,7 +198,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileFdWithHeader :: Socket -> Fd -> FileRange -> IO () -> [ByteString] -> IO () sendfileFdWithHeader sock fd range hook hdr = do
System/Linux/Sendfile.hs view
@@ -23,7 +23,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfile :: Fd -> ByteString -> FileRange -> IO () -> IO () sendfile = sendfile'@@ -42,7 +42,7 @@ -- The fourth action argument is called when a file is sent as chunks. -- Chucking is inevitable if the socket is non-blocking (this is the -- default) and the file is large. The action is called after a chunk--- is sent and bofore waiting the socket to be ready for writing.+-- is sent and before waiting the socket to be ready for writing. sendfileFd :: Fd -> Fd -> FileRange -> IO () -> IO () sendfileFd = sendfileFd'
simple-sendfile.cabal view
@@ -1,76 +1,91 @@-Name: simple-sendfile-Version: 0.2.30-Author: Kazu Yamamoto <kazu@iij.ad.jp>-Maintainer: Kazu Yamamoto <kazu@iij.ad.jp>-License: BSD3-License-File: LICENSE-Synopsis: Cross platform library for the sendfile system call-Description: Cross platform library for the sendfile system call.- This library tries to call minimum system calls which- are the bottleneck of web servers.-Category: Network-Cabal-Version: >= 1.10-Build-Type: Simple+cabal-version: >=1.10+name: simple-sendfile+version: 0.2.31+license: BSD3+license-file: LICENSE+maintainer: Kazu Yamamoto <kazu@iij.ad.jp>+author: Kazu Yamamoto <kazu@iij.ad.jp>+synopsis: Cross platform library for the sendfile system call+description:+ Cross platform library for the sendfile system call.+ This library tries to call minimum system calls which+ are the bottleneck of web servers. -Extra-source-files: test/inputFile+category: Network+build-type: Simple+extra-source-files: test/inputFile -Flag allow-bsd- Description: Allow use of BSD sendfile (disable on GNU/kFreeBSD)- Default: True+source-repository head+ type: git+ location: git://github.com/kazu-yamamoto/simple-sendfile -Library- Default-Language: Haskell2010- GHC-Options: -Wall- Exposed-Modules: Network.Sendfile- Other-Modules: Network.Sendfile.Types- Build-Depends: base >= 4.8 && < 5- , network- , bytestring- -- NetBSD and OpenBSD don't have sendfile- if os(freebsd) && flag(allow-bsd)- CPP-Options: -DOS_BSD- Other-Modules: Network.Sendfile.BSD- Network.Sendfile.IOVec- Build-Depends: unix- else- if os(darwin)- CPP-Options: -DOS_MacOS- Other-Modules: Network.Sendfile.BSD- Network.Sendfile.IOVec- Build-Depends: unix+flag allow-bsd+ description: Allow use of BSD sendfile (disable on GNU/kFreeBSD)++flag fallback+ description: Use counduit instead of sendfile()+ default: False++library+ exposed-modules: Network.Sendfile+ other-modules: Network.Sendfile.Types+ default-language: Haskell2010+ ghc-options: -Wall+ build-depends:+ base >=4.8 && <5,+ network,+ bytestring++ if (os(freebsd) && flag(allow-bsd) && !flag(fallback))+ cpp-options: -DOS_BSD+ other-modules:+ Network.Sendfile.BSD+ Network.Sendfile.IOVec++ build-depends: unix+ else- if os(linux)- CPP-Options: -DOS_Linux- Exposed-Modules: System.Linux.Sendfile- Other-Modules: Network.Sendfile.Linux- Build-Depends: unix- else- Other-Modules: Network.Sendfile.Fallback- Build-Depends: conduit >= 1.0 && < 1.4- , conduit-extra >= 1.0 && < 1.4- , transformers >= 0.2.2 && < 0.6- , resourcet+ if (os(osx) && !flag(fallback))+ cpp-options: -DOS_MacOS+ other-modules:+ Network.Sendfile.BSD+ Network.Sendfile.IOVec -Test-Suite spec- Type: exitcode-stdio-1.0- Default-Language: Haskell2010- Hs-Source-Dirs: test- Main-Is: Spec.hs- GHC-Options: -Wall- Other-Modules: SendfileSpec- Build-Depends: base- , HUnit- , bytestring- , conduit- , conduit-extra- , resourcet- , directory- , hspec >= 1.3- , network- , process- , simple-sendfile- , unix+ build-depends: unix -Source-Repository head- Type: git- Location: git://github.com/kazu-yamamoto/simple-sendfile+ else+ if (os(linux) && !flag(fallback))+ exposed-modules: System.Linux.Sendfile+ cpp-options: -DOS_Linux+ other-modules: Network.Sendfile.Linux+ build-depends: unix++ else+ other-modules: Network.Sendfile.Fallback+ build-depends:+ conduit >=1.0 && <1.4,+ conduit-extra >=1.0 && <1.4,+ transformers >=0.2.2 && <0.7,+ resourcet++test-suite spec+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ build-tool-depends: hspec-discover:hspec-discover+ hs-source-dirs: test+ other-modules: SendfileSpec+ default-language: Haskell2010+ ghc-options: -Wall+ build-depends:+ base,+ HUnit,+ bytestring,+ conduit,+ conduit-extra,+ resourcet,+ directory,+ hspec >=1.3,+ network,+ process,+ simple-sendfile,+ unix