snap-server 0.9.3.1 → 0.9.3.3
raw patch · 3 files changed
+30/−28 lines, 3 filesdep ~snap-core
Dependency ranges changed: snap-core
Files
- snap-server.cabal +2/−2
- src/Snap/Internal/Http/Server/Address.hs +25/−23
- test/snap-server-testsuite.cabal +3/−3
snap-server.cabal view
@@ -1,5 +1,5 @@ name: snap-server-version: 0.9.3.1+version: 0.9.3.3 synopsis: A fast, iteratee-based, epoll-enabled web server for the Snap Framework description: Snap is a simple and fast web development framework and server written in@@ -98,7 +98,7 @@ mtl >= 2 && < 3, network >= 2.3 && < 2.5, old-locale,- snap-core >= 0.9.3 && < 0.11,+ snap-core >= 0.9.3 && < 0.10, text >= 0.11 && < 0.12, time >= 1.0 && < 1.5, unix-compat >= 0.2 && < 0.5
src/Snap/Internal/Http/Server/Address.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE OverloadedStrings #-} module Snap.Internal.Http.Server.Address ( getHostAddr@@ -8,15 +8,15 @@ ) where -------------------------------------------------------------------------------import Network.Socket-import Data.Maybe-import Control.Monad import Control.Exception-import Data.Typeable-import Data.ByteString (ByteString)-import qualified Data.ByteString as S-import Data.ByteString.Char8 ()+import Control.Monad+import Data.ByteString (ByteString)+import qualified Data.ByteString as S+import Data.ByteString.Char8 () import Data.ByteString.Internal (c2w, w2c)+import Data.Maybe+import Data.Typeable+import Network.Socket ------------------------------------------------------------------------------ data AddressNotSupportedException = AddressNotSupportedException String@@ -46,20 +46,22 @@ getSockAddr :: Int -> ByteString -> IO (Family, SockAddr)-getSockAddr p s | s == "*" = ipV4Addr p iNADDR_ANY-getSockAddr p s | s == "::" = ipV6Addr p iN6ADDR_ANY+getSockAddr p s | s == "*" =+ return $! ( AF_INET+ , SockAddrInet (fromIntegral p) iNADDR_ANY+ )+getSockAddr p s | s == "::" =+ return $! ( AF_INET6+ , SockAddrInet6 (fromIntegral p) 0 iN6ADDR_ANY 0+ ) getSockAddr p s = do- let hints = defaultHints { addrFlags = [AI_NUMERICHOST] }- ai <- getAddrInfo (Just hints) (Just $ map w2c $ S.unpack s) Nothing- if ai == [] then throwIO $ AddressNotSupportedException $ show s+ let hints = defaultHints { addrFlags = [AI_NUMERICSERV] }+ ais <- getAddrInfo (Just hints) (Just $ map w2c $ S.unpack s)+ (Just $ show p)+ if null ais+ then throwIO $ AddressNotSupportedException $ show s else do- case addrAddress $ head ai of- SockAddrInet _ h -> ipV4Addr p h- SockAddrInet6 _ _ h _ -> ipV6Addr p h- x -> throwIO $ AddressNotSupportedException $ show x--ipV4Addr :: Int -> HostAddress -> IO (Family, SockAddr)-ipV4Addr p h = return (AF_INET, SockAddrInet (fromIntegral p) h)--ipV6Addr :: Int -> HostAddress6 -> IO (Family, SockAddr)-ipV6Addr p h = return (AF_INET6, SockAddrInet6 (fromIntegral p) 0 h 0)+ let ai = head ais+ let fm = addrFamily ai+ let sa = addrAddress ai+ return (fm, sa)
test/snap-server-testsuite.cabal view
@@ -39,7 +39,7 @@ old-locale, parallel >= 2 && <4, process,- snap-core >= 0.9.3 && <0.11,+ snap-core >= 0.9.3 && <0.10, template-haskell, test-framework >= 0.6 && <0.7, test-framework-hunit >= 0.2.7 && <0.3,@@ -104,7 +104,7 @@ parallel >= 3.2 && <4, MonadCatchIO-transformers >= 0.2.1 && <0.4, network >= 2.3 && <2.5,- snap-core >= 0.9.3 && <0.11,+ snap-core >= 0.9.3 && <0.10, template-haskell, time, transformers,@@ -170,7 +170,7 @@ network >= 2.3 && <2.5, old-locale, parallel >= 3.2 && <4,- snap-core >= 0.9.3 && <0.11,+ snap-core >= 0.9.3 && <0.10, template-haskell, test-framework >= 0.6 && <0.7, test-framework-hunit >= 0.2.7 && <0.3,