on master help sign in
new connSendFile.

Plain HTTP: Linux/FreeBSD/Mac: using sendfileFdWithHeader of simple-sendfile Other BSDs: using readSendFile with FdCache Windows: using readSendFile HTTP over TLS: Unix: using readSendFile with FdCache Windows: using readSendFile

commit269aa54a551460df077796910ca0d4cdfa08998e authorKazu Yamamoto <kazu@iij.ad.jp> dateThu 11 Jun 2015, 15:54 (11 years ago) parent1c461e4
2 files changed+8−9
warp/Network/Wai/Handler/Warp/Run.hs+3−2 warp/Network/Wai/Handler/Warp/SendFile.hs+5−7
warp/Network/Wai/Handler/Warp/Run.hs+3−2
@@ -50,10 +50,11 @@ socketConnection :: Socket -> IO Connection
5050socketConnection s = do
5151 bufferPool <- newBufferPool
5252 writeBuf <- allocateBuffer bufferSize
53+ let sendall = Sock.sendAll s
5354 return Connection {
5455 connSendMany = Sock.sendMany s
55− , connSendAll = Sock.sendAll s
56− , connSendFile = defaultSendFile s
56+ , connSendAll = sendall
57+ , connSendFile = defaultSendFile s writeBuf bufferSize sendall
5758 , connClose = sClose s >> freeBuffer writeBuf
5859 , connRecv = receive s bufferPool
5960 , connBufferPool = bufferPool
warp/Network/Wai/Handler/Warp/SendFile.hs+5−7
@@ -21,19 +21,17 @@ import System.Posix.Types
2121
2222----------------------------------------------------------------
2323
24−defaultSendFile :: Socket -> SendFile
24+defaultSendFile :: Socket -> Buffer -> BufSize -> (ByteString -> IO ()) -> SendFile
2525#ifdef SENDFILEFD
26−defaultSendFile s fid off len act hdr = case mfid of
27− Nothing -> sendfileWithHeader s path (PartOfFile off len) act hdr
26+defaultSendFile s _ _ _ fid off len act hdr = case mfid of
2827 Just fd -> sendfileFdWithHeader s fd (PartOfFile off len) act hdr
28+ -- never reached, just in case
29+ Nothing -> sendfileWithHeader s path (PartOfFile off len) act hdr
2930 where
3031 path = fileIdPath fid
3132 mfid = fileIdFd fid
3233#else
33−defaultSendFile s fid off len act hdr =
34− sendfileWithHeader s path (PartOfFile off len) act hdr
35− where
36− path = fileIdPath fid
34+defaultSendFile _ = readSendFile
3735#endif
3836
3937----------------------------------------------------------------