warp-3.0.13: A fast, light-weight web server for WAI applications.

Safe HaskellNone
LanguageHaskell98

Network.Wai.Handler.Warp.Timeout

Contents

Description

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.

Synopsis

Types

type Manager = Reaper [Handle] Handle Source

A timeout manager

type TimeoutAction = IO () Source

An action to be performed on timeout.

data Handle Source

A handle used by Manager

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.

withManager Source

Arguments

:: Int

timeout in microseconds

-> (Manager -> IO a) 
-> IO a 

Call the inner function with a timeout manager.

Registration

register :: Manager -> TimeoutAction -> IO Handle Source

Registering a timeout action.

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.

pause :: Handle -> IO () Source

Setting the state to paused. Manager does not change the value.

resume :: Handle -> IO () Source

Setting the paused state to active. This is an alias to tickle.

Exceptions