Various Warp server settings. This is purposely kept as an abstract data type so that new settings can be added without breaking backwards compatibility. In order to create a Settings value, use defaultSettings and the various 'set' functions to modify individual fields. For example:
setTimeout 20 defaultSettingsConstructors
SettingssettingsPort :: PortPort to listen on. Default value: 3000
settingsHost :: HostPreferenceDefault value: HostIPv4
settingsOnException :: Maybe Request -> SomeException -> IO ()What to do with exceptions thrown by either the application or server. Default: ignore server-generated exceptions (see InvalidRequest) and print application-generated applications to stderr.
settingsOnExceptionResponse :: SomeException -> ResponseA function to create Response when an exception occurs.
Default: 500, text/plain, "Something went wrong"
Since 2.0.3
settingsOnOpen :: SockAddr -> IO BoolsettingsOnClose :: SockAddr -> IO ()What to do when a connection is close. Default: do nothing.
settingsTimeout :: IntTimeout value in seconds. Default value: 30
settingsManager :: Maybe ManagerUse an existing timeout manager instead of spawning a new one. If used, settingsTimeout is ignored. Default is Nothing
settingsFdCacheDuration :: IntCache duration time of file descriptors in seconds. 0 means that the cache mechanism is not used. Default value: 0
settingsFileInfoCacheDuration :: IntCache duration time of file information in seconds. 0 means that the cache mechanism is not used. Default value: 0
settingsBeforeMainLoop :: IO ()Code to run after the listening socket is ready but before entering the main event loop. Useful for signaling to tests that they can start running, or to drop permissions after binding to a restricted port.
Default: do nothing.
Since 1.3.6
settingsFork :: ((forall a. IO a -> IO a) -> IO ()) -> IO ()Code to fork a new thread to accept a connection.
This may be useful if you need OS bound threads, or if you wish to develop an alternative threading model.
Default:
defaultForkSince 3.0.4
settingsAccept :: Socket -> IO (Socket, SockAddr)Code to accept a new connection.
Useful if you need to provide connected sockets from something other than a standard accept call.
Default:
defaultAcceptSince 3.3.24
settingsNoParsePath :: BoolPerform no parsing on the rawPathInfo.
This is useful for writing HTTP proxies.
Default: False
Since 2.0.3
settingsInstallShutdownHandler :: IO () -> IO ()An action to install a handler (e.g. Unix signal handler) to close a listen socket. The first argument is an action to close the listen socket.
Default: no action
Since 3.0.1
settingsServerName :: ByteStringDefault server name if application does not set one.
Since 3.0.2
settingsMaximumBodyFlush :: Maybe IntSee
setMaximumBodyFlush.Since 3.0.3
settingsProxyProtocol :: ProxyProtocolSpecify usage of the PROXY protocol.
Since 3.0.5
settingsSlowlorisSize :: IntSize of bytes read to prevent Slowloris protection. Default value: 2048
Since 3.1.2
settingsHTTP2Enabled :: BoolWhether to enable HTTP2 ALPN/upgrades. Default: True
Since 3.1.7
settingsLogger :: Request -> Status -> Maybe Integer -> IO ()A log function. Default: no action.
Since 3.1.10
settingsServerPushLogger :: Request -> ByteString -> Integer -> IO ()A HTTP/2 server push log function. Default: no action.
Since 3.2.7
settingsGracefulShutdownTimeout :: Maybe IntAn optional timeout to limit the time (in seconds) waiting for a graceful shutdown of the web server.
Since 3.2.8
settingsGracefulCloseTimeout1 :: IntA timeout to limit the time (in milliseconds) waiting for FIN for HTTP/1.x. 0 means uses immediate close. Default: 0.
Since 3.3.5
settingsGracefulCloseTimeout2 :: IntA timeout to limit the time (in milliseconds) waiting for FIN for HTTP/2. 0 means uses immediate close. Default: 2000.
Since 3.3.5
settingsMaxTotalHeaderLength :: IntDetermines the maximum header size that Warp will tolerate when using HTTP/1.x.
Since 3.3.8
settingsAltSvc :: Maybe ByteStringSpecify the header value of Alternative Services (AltSvc:).
Default: Nothing
Since 3.3.11
settingsMaxBuilderResponseBufferSize :: IntDetermines the maxium buffer size when sending
Builderresponses (See responseBuilder).When sending a builder response warp uses a 16 KiB buffer to write the builder to. When that buffer is too small to fit the builder warp will free it and create a new one that will fit the builder.
To protect against allocating too large a buffer warp will error if the builder requires more than this maximum.
Default: 1049_000_000 = 1 MiB.
Since 3.3.22