Safe Haskell | None |
---|---|
Language | Haskell98 |
In order to provide slowloris protection, Warp provides timeout handlers. We follow these rules:
- A timeout is created when a connection is opened.
- When all request headers are read, the timeout is tickled.
- Every time at least 2048 bytes of the request body are read, the timeout is tickled.
- The timeout is paused while executing user code. This will apply to both the application itself, and a ResponseSource response. The timeout is resumed as soon as we return from user code.
- Every time data is successfully sent to the client, the timeout is tickled.
- type Manager = Reaper [Handle] Handle
- type TimeoutAction = IO ()
- data Handle
- initialize :: Int -> IO Manager
- stopManager :: Manager -> IO ()
- withManager :: Int -> (Manager -> IO a) -> IO a
- register :: Manager -> TimeoutAction -> IO Handle
- registerKillThread :: Manager -> IO Handle
- tickle :: Handle -> IO ()
- cancel :: Handle -> IO ()
- pause :: Handle -> IO ()
- resume :: Handle -> IO ()
- data TimeoutThread = TimeoutThread
Types
type TimeoutAction = IO () Source
An action to be performed on timeout.
Manager
initialize :: Int -> IO Manager Source
Creating timeout manager which works every N micro seconds where N is the first argument.
stopManager :: Manager -> IO () Source
Stopping timeout manager.
Call the inner function with a timeout manager.
Registration
registerKillThread :: Manager -> IO Handle Source
Registering a timeout action of killing this thread.
Control
tickle :: Handle -> IO () Source
Setting the state to active.
Manager
turns active to inactive repeatedly.
cancel :: Handle -> IO () Source
Setting the state to canceled.
Manager
eventually removes this without timeout action.