Skip to content

fix deprecations from Network.Socket. #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/Snap/Internal/Http/Server/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 $
Expand Down
4 changes: 4 additions & 0 deletions src/Snap/Internal/Http/Server/TLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down