http2-tls-0.4.5: Library for HTTP/2 over TLS
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.HTTP2.TLS.Server

Synopsis

Runners

run :: Settings -> Credentials -> HostName -> PortNumber -> Server -> IO () Source #

Running an HTTP/2 client over TLS (over TCP). ALPN is "h2".

runWithSocket :: Settings -> Credentials -> Socket -> Server -> IO () Source #

Running an HTTP/2 client over TLS (over TCP). ALPN is "h2".

runH2C :: Settings -> HostName -> PortNumber -> Server -> IO () Source #

Running an HTTP/2 client over TCP.

runH2CWithSocket :: Settings -> Socket -> Server -> IO () Source #

Running an HTTP/2 client over TCP.

type Server = Request -> Aux -> (Response -> [PushPromise] -> IO ()) -> IO () #

Server type. Server takes a HTTP request, should generate a HTTP response and push promises, then should give them to the sending function. The sending function would throw exceptions so that they can be logged.

The sending function must only be called once.

type HostName = String #

Either a host name e.g., "haskell.org" or a numeric host address string consisting of a dotted decimal IPv4 address or an IPv6 address e.g., "192.168.0.1".

data PortNumber #

Port number. Use the Num instance (i.e. use a literal) to create a PortNumber value.

>>> 1 :: PortNumber
1
>>> read "1" :: PortNumber
1
>>> show (12345 :: PortNumber)
"12345"
>>> 50000 < (51000 :: PortNumber)
True
>>> 50000 < (52000 :: PortNumber)
True
>>> 50000 + (10000 :: PortNumber)
60000

Instances

Instances details
Storable PortNumber 
Instance details

Defined in Network.Socket.Types

Bounded PortNumber 
Instance details

Defined in Network.Socket.Types

Enum PortNumber 
Instance details

Defined in Network.Socket.Types

Num PortNumber 
Instance details

Defined in Network.Socket.Types

Read PortNumber 
Instance details

Defined in Network.Socket.Types

Integral PortNumber 
Instance details

Defined in Network.Socket.Types

Real PortNumber 
Instance details

Defined in Network.Socket.Types

Show PortNumber 
Instance details

Defined in Network.Socket.Types

Eq PortNumber 
Instance details

Defined in Network.Socket.Types

Ord PortNumber 
Instance details

Defined in Network.Socket.Types

runTLS Source #

Arguments

:: Settings 
-> Credentials 
-> HostName 
-> PortNumber 
-> ByteString

ALPN

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

Running a TLS client. IOBackend provides sending and receiving functions with timeout based on Settings.

runTLSWithSocket Source #

Arguments

:: Settings 
-> Credentials 
-> Socket 
-> ByteString

ALPN

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

Running a TLS client. IOBackend provides sending and receiving functions with timeout based on Settings.

Settings

defaultSettings :: Settings Source #

Default settings.

settingsTimeout :: Settings -> Int Source #

Timeout in seconds. (All)

>>> settingsTimeout defaultSettings
30

settingsSendBufferSize :: Settings -> Int Source #

Send buffer size. (H2 and H2c)

>>> settingsSendBufferSize defaultSettings
4096

settingsSlowlorisSize :: Settings -> Int Source #

If the size of receiving data is less than or equal, the timeout is not reset. (All)

>>> settingsSlowlorisSize defaultSettings
50

settingsReadBufferSize :: Settings -> Int Source #

When the size of a read buffer is lower than this limit, the buffer is thrown awany (and is eventually freed). Then a new buffer is allocated. (All)

>>> settingsReadBufferSize defaultSettings
16384

settingsReadBufferLowerLimit :: Settings -> Int Source #

The allocation size for a read buffer. (All)

>>> settingsReadBufferLowerLimit defaultSettings
2048

settingsKeyLogger :: Settings -> String -> IO () Source #

Key logger.

Applications may wish to set this depending on the SSLKEYLOGFILE environment variable. The default is do nothing.

Default: do nothing

settingsNumberOfWorkers :: Settings -> Int Source #

Deprecated: This field is meaningless now

The http2 library now spawns a thread for each connection. Its limit is based on settingsConcurrentStreams.

settingsConcurrentStreams :: Settings -> Int Source #

The maximum number of incoming streams on the net (H2 and H2c)

>>> settingsConcurrentStreams defaultSettings
64

settingsConnectionWindowSize :: Settings -> Int Source #

The window size of a connection (H2 and H2c)

>>> settingsConnectionWindowSize defaultSettings
1048575

settingsStreamWindowSize :: Settings -> Int Source #

The window size of incoming streams (H2 and H2c)

>>> settingsStreamWindowSize defaultSettings
262144

settingsSessionManager :: Settings -> SessionManager Source #

TLS session manager (H2 and TLS)

Default: noSessionManager

settingsEarlyDataSize :: Settings -> Int Source #

The max size of early data (0-RTT) to be accepted. (H2 and TLS) 0 means that early data is not accepted.

>>> settingsEarlyDataSize defaultSettings
0

Rate limits

settingsPingRateLimit :: Settings -> Int Source #

Maximum number of pings allowed per second (CVE-2019-9512)

>>> settingsPingRateLimit defaultSettings
10

settingsEmptyFrameRateLimit :: Settings -> Int Source #

Maximum number of empty data frames allowed per second (CVE-2019-9518)

>>> settingsEmptyFrameRateLimit defaultSettings
4

settingsSettingsRateLimit :: Settings -> Int Source #

Maximum number of settings frames allowed per second (CVE-2019-9515)

>>> settingsSettingsRateLimit defaultSettings
4

settingsRstRateLimit :: Settings -> Int Source #

Maximum number of reset frames allowed per second (CVE-2023-44487)

>>> settingsRstRateLimit
4

IO backend

data IOBackend Source #

Sending and receiving functions. Tiemout is reset when they return. One exception is the slowloris attach prevention. See settingsSlowlorisSize.

send :: IOBackend -> ByteString -> IO () Source #

Sending.

sendMany :: IOBackend -> [ByteString] -> IO () Source #

Sending many.

requestSock :: IOBackend -> Socket Source #

The socket for the request

Internal

runIO :: Settings -> Credentials -> Socket -> (ServerIO Stream -> IO (IO ())) -> IO () Source #

runIOH2C :: Settings -> Socket -> (ServerIO Stream -> IO (IO ())) -> IO () Source #

data Stream #

Instances

Instances details
Show Stream 
Instance details

Defined in Network.HTTP2.H2.Types

data ServerIO a #

Constructors

ServerIO 

Fields