@@ -14,7 +14,9 @@ import Data.Conduit.Internal (ResumableSource (..))
1414import qualified Data.Conduit.List as CL
1515import Data.Conduit.Network (bindPort)
1616import Network (sClose, Socket)
17+import Network.Sendfile
1718import Network.Socket (accept, SockAddr)
19+import qualified Network.Socket.ByteString as Sock
1820import Network.Wai
1921import Network.Wai.Handler.Warp.Request
2022import Network.Wai.Handler.Warp.Response
@@ -28,6 +30,15 @@ import qualified Control.Concurrent.MVar as MV
2830import Network.Socket (withSocketsDo)
2931#endif
3032
33+socketConnection :: Socket -> Connection
34+socketConnection s = Connection
35+ { connSendMany = Sock.sendMany s
36+ , connSendAll = Sock.sendAll s
37+ , connSendFile = \fp off len act hdr -> sendfileWithHeader s fp (PartOfFile off len) act hdr
38+ , connClose = sClose s
39+ , connRecv = Sock.recv s bytesPerRead
40+ }
41+
3142#if __GLASGOW_HASKELL__ < 702
3243allowInterrupt :: IO ()
3344allowInterrupt = unblock $ return ()