@@ -70,12 +70,14 @@ module Network.Wai.Handler.Warp (
7070 , setSlowlorisSize
7171 , setHTTP2Disabled
7272 , setLogger
73+ , setGracefulShutdownTimeout
7374 -- ** Getters
7475 , getPort
7576 , getHost
7677 , getOnOpen
7778 , getOnClose
7879 , getOnException
80+ , getGracefulShutdownTimeout
7981 -- ** Exception handler
8082 , defaultOnException
8183 , defaultShouldDisplayException
@@ -244,6 +246,10 @@ getOnClose = settingsOnClose
244246getOnException :: Settings -> Maybe Request -> SomeException -> IO ()
245247getOnException = settingsOnException
246248
249+-- | Get the graceful shutdown timeout
250+getGracefulShutdownTimeout :: Settings -> Maybe Int
251+getGracefulShutdownTimeout = settingsGracefulShutdownTimeout
252+
247253-- | A code to install shutdown handler.
248254--
249255-- For instance, this code should set up a UNIX signal
@@ -347,6 +353,13 @@ setLogger :: (Request -> H.Status -> Maybe Integer -> IO ())
347353 -> Settings -> Settings
348354setLogger lgr y = y { settingsLogger = lgr }
349355
356+-- | Set the graceful shutdown timeout. A timeout of `Nothing' will
357+-- wait indefinitely, and a number, if provided, will be treated as seconds
358+-- to wait for requests to finish, before shutting down the server entirely.
359+setGracefulShutdownTimeout :: Maybe Int
360+ -> Settings -> Settings
361+setGracefulShutdownTimeout time y = y { settingsGracefulShutdownTimeout = time }
362+
350363-- | Explicitly pause the slowloris timeout.
351364--
352365-- This is useful for cases where you partially consume a request body. For