diff --git a/src/Snap/Internal/Http/Server/Socket.hs b/src/Snap/Internal/Http/Server/Socket.hs index 42b962ae..b1964fe7 100644 --- a/src/Snap/Internal/Http/Server/Socket.hs +++ b/src/Snap/Internal/Http/Server/Socket.hs @@ -174,16 +174,14 @@ sendFileFunc :: Socket -> SendFileHandler sendFileFunc sock !_ builder fPath offset nbytes = bracket acquire closeFd go where acquire = openFd fPath ReadOnly Nothing defaultFileFlags + go fileFd = do #if MIN_VERSION_network(3,0,0) - go fileFd = do sockFd <- Fd `fmap` fdSocket sock - sendHeaders builder sockFd - sendFile sockFd fileFd offset nbytes + sockFd <- Fd `fmap` fdSocket sock #else - go fileFd = do let sockFd = Fd $ fdSocket sock + let sockFd = Fd $ fdSocket sock +#endif sendHeaders builder sockFd sendFile sockFd fileFd offset nbytes -#endif - #else sendFileFunc sock buffer builder fPath offset nbytes = Streams.unsafeWithFileAsInputStartingAt (fromIntegral offset) fPath $ diff --git a/src/Snap/Internal/Http/Server/TLS.hs b/src/Snap/Internal/Http/Server/TLS.hs index 551966f5..bedae57a 100644 --- a/src/Snap/Internal/Http/Server/TLS.hs +++ b/src/Snap/Internal/Http/Server/TLS.hs @@ -105,7 +105,11 @@ bindHttps bindAddress bindPort cert chainCert key = (Socket.close . fst) $ \(sock, addr) -> do Socket.setSocketOption sock Socket.ReuseAddr 1 +#if MIN_VERSION_network(2,7,0) + Socket.bind sock addr +#else Socket.bindSocket sock addr +#endif Socket.listen sock 150 ctx <- SSL.context