packages feed

warp 1.3.8.1 → 1.3.8.2

raw patch · 2 files changed

+25/−12 lines, 2 files

Files

Network/Wai/Handler/Warp/Settings.hs view
@@ -1,15 +1,16 @@ module Network.Wai.Handler.Warp.Settings where  import Control.Exception-import Control.Monad import qualified Data.ByteString as S import qualified Data.ByteString.Char8 as S8 import Data.Conduit import Data.Conduit.Network (HostPreference (HostIPv4))+import GHC.IO.Exception (IOErrorType(..)) import Network.Wai import Network.Wai.Handler.Warp.Timeout import Network.Wai.Handler.Warp.Types import System.IO (hPrint, stderr)+import System.IO.Error (ioeGetErrorType)  -- | Various Warp server settings. This is purposely kept as an abstract data -- type so that new settings can be added without breaking backwards@@ -54,12 +55,7 @@ defaultSettings = Settings     { settingsPort = 3000     , settingsHost = HostIPv4-    , settingsOnException = \e ->-        case fromException e of-            Just x -> go x-            Nothing ->-                when (go' $ fromException e) $-                    hPrint stderr e+    , settingsOnException = defaultExceptionHandler     , settingsOnOpen = return ()     , settingsOnClose = return ()     , settingsTimeout = 30@@ -70,8 +66,25 @@     , settingsBeforeMainLoop = return ()     , settingsServerName = S8.pack $ "Warp/" ++ warpVersion     }++defaultExceptionHandler :: SomeException -> IO ()+defaultExceptionHandler e = throwIO e `catches` handlers   where-    go :: InvalidRequest -> IO ()-    go _ = return ()-    go' (Just ThreadKilled) = False-    go' _ = True+    handlers = [Handler ah, Handler ih, Handler oh, Handler sh]++    ah :: AsyncException -> IO ()+    ah ThreadKilled = return ()+    ah x            = hPrint stderr x++    ih :: InvalidRequest -> IO ()+    ih _ = return ()++    oh :: IOException -> IO ()+    oh x+      | et == ResourceVanished || et == InvalidArgument = return ()+      | otherwise         = hPrint stderr x+      where+        et = ioeGetErrorType x++    sh :: SomeException -> IO ()+    sh x = hPrint stderr x
warp.cabal view
@@ -1,5 +1,5 @@ Name:                warp-Version:             1.3.8.1+Version:             1.3.8.2 Synopsis:            A fast, light-weight web server for WAI applications. License:             MIT License-file:        LICENSE