Skip to content
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

Fixed all warnings, all travis tests good #132

Open
wants to merge 4 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
1 change: 1 addition & 0 deletions snap-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ Executable snap-test-server
clock,
containers,
directory,
filepath,
io-streams,
io-streams-haproxy,
lifted-base,
Expand Down
14 changes: 7 additions & 7 deletions src/Snap/Internal/Http/Server/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import Control.Monad (liftM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as S
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Typeable (Typeable)
import Network.Socket (AddrInfo (addrAddress, addrFamily, addrFlags, addrSocketType), AddrInfoFlag (AI_NUMERICSERV, AI_PASSIVE), Family (AF_INET, AF_INET6), HostName, NameInfoFlag (NI_NUMERICHOST), ServiceName, SockAddr (SockAddrInet, SockAddrInet6, SockAddrUnix), SocketType (Stream), defaultHints, getAddrInfo, getNameInfo)
import Network.Socket (AddrInfo (addrAddress, addrFamily, addrFlags, addrSocketType), AddrInfoFlag (AI_NUMERICSERV, AI_PASSIVE), Family (AF_INET, AF_INET6), HostName, NameInfoFlag (NI_NUMERICHOST), ServiceName, SockAddr (SockAddrInet, SockAddrInet6), SocketType (Stream), defaultHints, getAddrInfo, getNameInfo)


------------------------------------------------------------------------------
Expand Down Expand Up @@ -65,13 +63,15 @@ getAddressImpl !_getHostAddr addr =
case addr of
SockAddrInet p _ -> host (fromIntegral p)
SockAddrInet6 p _ _ _ -> host (fromIntegral p)
SockAddrUnix path -> return (-1, prefix path)
#if MIN_VERSION_network(2,6,0)
_ -> fail "Unsupported address type"
where
host port = (,) port . S.pack <$> _getHostAddr addr
#else
SockAddrUnix path -> return (-1, prefix path)
where
prefix path = T.encodeUtf8 $! T.pack $ "unix:" ++ path
#endif
where
prefix path = T.encodeUtf8 $! T.pack $ "unix:" ++ path
host port = (,) port . S.pack <$> _getHostAddr addr


------------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion src/Snap/Internal/Http/Server/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import Data.Maybe (fromJust, fromMaybe,
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mconcat)
#endif
import Data.Monoid ((<>))
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup (..))
#endif
import Data.Monoid ()
import Data.Time.Format (formatTime)
import Data.Typeable (Typeable)
import Data.Version (showVersion)
Expand Down
6 changes: 5 additions & 1 deletion src/Snap/Internal/Http/Server/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import Data.ByteString.Char8 (ByteString)
import Network.Socket (Socket, SocketOption (NoDelay, ReuseAddr), accept, close, getSocketName, setSocketOption, socket)
import qualified Network.Socket as N
#ifdef HAS_SENDFILE
#if MIN_VERSION_network(3,0,0)
import Network.Socket (unsafeFdSocket)
#else
import Network.Socket (fdSocket)
#endif
import System.Posix.IO (OpenMode (..), closeFd, defaultFileFlags, openFd)
import System.Posix.Types (Fd (..))
import System.SendFile (sendFile, sendHeaders)
Expand Down Expand Up @@ -175,7 +179,7 @@ sendFileFunc sock !_ builder fPath offset nbytes = bracket acquire closeFd go
where
acquire = openFd fPath ReadOnly Nothing defaultFileFlags
#if MIN_VERSION_network(3,0,0)
go fileFd = do sockFd <- Fd `fmap` fdSocket sock
go fileFd = do sockFd <- Fd `fmap` unsafeFdSocket sock
sendHeaders builder sockFd
sendFile sockFd fileFd offset nbytes
#else
Expand Down
2 changes: 1 addition & 1 deletion src/Snap/Internal/Http/Server/TLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bindHttps bindAddress bindPort cert chainCert key =
(Socket.close . fst)
$ \(sock, addr) -> do
Socket.setSocketOption sock Socket.ReuseAddr 1
Socket.bindSocket sock addr
Socket.bind sock addr
Socket.listen sock 150

ctx <- SSL.context
Expand Down
4 changes: 2 additions & 2 deletions test/Paths_snap_server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Paths_snap_server (
version
) where

import Data.Version (Version (..))
import Data.Version (Version, makeVersion)

version :: Version
version = Version {versionBranch = [0,0,0], versionTags = ["unknown"]}
version = makeVersion [0,0,0]