on master help sign in
doc update.
commit4be9041a1728fb23bcd45dd122bc5278ef9898b4 authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 17 Jun 2015, 11:37 (11 years ago) parentf90b710
3 files changed+12−5
warp/Network/Wai/Handler/Warp.hs+1 warp/Network/Wai/Handler/Warp/Run.hs+1−1 warp/Network/Wai/Handler/Warp/SendFile.hs+10−4
warp/Network/Wai/Handler/Warp.hs+1
@@ -103,6 +103,7 @@ module Network.Wai.Handler.Warp (
103103 -- ** Sendfile
104104 , FileId (..)
105105 , SendFile
106+ , sendFile
106107 , readSendFile
107108 -- * Internal
108109 -- ** Version
warp/Network/Wai/Handler/Warp/Run.hs+1−1
@@ -54,7 +54,7 @@ socketConnection s = do
5454 return Connection {
5555 connSendMany = Sock.sendMany s
5656 , connSendAll = sendall
57− , connSendFile = defaultSendFile s writeBuf bufferSize sendall
57+ , connSendFile = sendFile s writeBuf bufferSize sendall
5858 , connClose = sClose s >> freeBuffer writeBuf
5959 , connRecv = receive s bufferPool
6060 , connWriteBuffer = writeBuf
warp/Network/Wai/Handler/Warp/SendFile.hs+10−4
@@ -1,7 +1,7 @@
11{-# LANGUAGE CPP, ForeignFunctionInterface #-}
22
33module Network.Wai.Handler.Warp.SendFile (
4− defaultSendFile
4+ sendFile
55 , readSendFile
66 , packHeader -- for testing
77 ) where
@@ -32,9 +32,12 @@ import System.Posix.Types
3232
3333----------------------------------------------------------------
3434
35−defaultSendFile :: Socket -> Buffer -> BufSize -> (ByteString -> IO ()) -> SendFile
35+-- | Function to send a file based on sendfiel() for Linux\/Mac\/FreeBSD.
36+-- This makes use of the file descriptor cache.
37+-- For other OSes, this is identical to 'readSendFile'.
38+sendFile :: Socket -> Buffer -> BufSize -> (ByteString -> IO ()) -> SendFile
3639#ifdef SENDFILEFD
37−defaultSendFile s _ _ _ fid off len act hdr = case mfid of
40+sendFile s _ _ _ fid off len act hdr = case mfid of
3841 -- settingsFdCacheDuration is 0
3942 Nothing -> sendfileWithHeader s path (PartOfFile off len) act hdr
4043 Just fd -> sendfileFdWithHeader s fd (PartOfFile off len) act hdr
@@ -42,7 +45,7 @@ defaultSendFile s _ _ _ fid off len act hdr = case mfid of
4245 mfid = fileIdFd fid
4346 path = fileIdPath fid
4447#else
45−defaultSendFile _ = readSendFile
48+sendFile _ = readSendFile
4649#endif
4750
4851----------------------------------------------------------------
@@ -74,6 +77,9 @@ mini i n
7477 | fromIntegral i < n = i
7578 | otherwise = fromIntegral n
7679
80+-- | Function to send a file based on pread()\/send() for Unix.
81+-- This makes use of the file descriptor cache.
82+-- For Windows, this is emulated by 'Handle'.
7783#ifdef WINDOWS
7884readSendFile :: Buffer -> BufSize -> (ByteString -> IO ()) -> SendFile
7985readSendFile buf siz send fid off0 len0 hook headers = do