on master help sign in
new connSendFile.
269aa54Kazu Yamamoto
warp/Network/Wai/Handler/Warp/Run.hs+3−2
@@ -50,10 +50,11 @@ socketConnection :: Socket -> IO Connection
50socketConnection s = do
50socketConnection s = do
51 bufferPool <- newBufferPool
51 bufferPool <- newBufferPool
52 writeBuf <- allocateBuffer bufferSize
52 writeBuf <- allocateBuffer bufferSize
53+ let sendall = Sock.sendAll s
53 return Connection {
54 return Connection {
54 connSendMany = Sock.sendMany s
55 connSendMany = Sock.sendMany s
55− , connSendAll = Sock.sendAll s
56+ , connSendAll = sendall
56− , connSendFile = defaultSendFile s
57+ , connSendFile = defaultSendFile s writeBuf bufferSize sendall
57 , connClose = sClose s >> freeBuffer writeBuf
58 , connClose = sClose s >> freeBuffer writeBuf
58 , connRecv = receive s bufferPool
59 , connRecv = receive s bufferPool
59 , connBufferPool = bufferPool
60 , connBufferPool = bufferPool
warp/Network/Wai/Handler/Warp/SendFile.hs+5−7
@@ -21,19 +21,17 @@ import System.Posix.Types
21
21
22----------------------------------------------------------------
22----------------------------------------------------------------
23
23
24−defaultSendFile :: Socket -> SendFile
24+defaultSendFile :: Socket -> Buffer -> BufSize -> (ByteString -> IO ()) -> SendFile
25#ifdef SENDFILEFD
25#ifdef SENDFILEFD
26−defaultSendFile s fid off len act hdr = case mfid of
26+defaultSendFile s _ _ _ fid off len act hdr = case mfid of
27− Nothing -> sendfileWithHeader s path (PartOfFile off len) act hdr
28 Just fd -> sendfileFdWithHeader s fd (PartOfFile off len) act hdr
27 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
29 where
30 where
30 path = fileIdPath fid
31 path = fileIdPath fid
31 mfid = fileIdFd fid
32 mfid = fileIdFd fid
32#else
33#else
33−defaultSendFile s fid off len act hdr =
34+defaultSendFile _ = readSendFile
34− sendfileWithHeader s path (PartOfFile off len) act hdr
35− where
36− path = fileIdPath fid
37#endif
35#endif
38
36
39----------------------------------------------------------------
37----------------------------------------------------------------