http2-manager-0.0.1: Managed connection pool for HTTP2
Safe HaskellSafe-Inferred
LanguageHaskell2010

HTTP2.Client.Manager

Synopsis

Documentation

data Http2Manager Source #

FUTUREWORK: Support HTTPS, perhaps ALPN negotiation can also be used to HTTP1. I think HTTP1 vs HTTP2 can not be negotated without TLS, so perhaps this manager will default to HTTP2.

setCacheLimit :: Int -> Http2Manager -> Http2Manager Source #

Warning: This won't affect already established connections

setSSLContext :: SSLContext -> Http2Manager -> Http2Manager Source #

Warning: This won't affect already established connections

setSSLRemoveTrailingDot :: Bool -> Http2Manager -> Http2Manager Source #

Remove traling dots in hostname while verifying hostname in the certificate presented by the server. For instance, when connecting with 'foo.example.com.' (Note the trailing dot) by default most SSL libraries fail hostname verification if the server has a certificate for 'foo.example.com' (Note the lack of a trailing dot). Setting this flag makes the hostname verification succeed for these hosts. However, this will make the hostname verification fail if the host presents a certificate which does have a trailing dot.

Discussion about why this is not implemented as a flag on SSLContext: https://github.com/openssl/openssl/issues/11560

Warning: This won't affect already established connections

type Port = Int Source #

withHTTP2Request :: Http2Manager -> Target -> Request -> (Response -> IO a) -> IO a Source #

Make an HTTP2 request, if it is the first time the Http2Manager sees this target, it creates the connection and keeps it around for any subsequent requests. Subsequest requests try to use this connection, in case the connection is already dead (e.g. the background thread has finished), a new connection is created.

It is important that the continuation provided by the caller of this function consumes the response body completely before it returns.

NOTE: If many concurrent requests are made to the same server using a single instance of Http2Manager, it could cause the manager to make multiple connections to the server. Eventually only one connection will be kept open. This, in theory, would cause some contention over STM based Map that the Http2Manager keeps and so could decrease throughput. In cases where many concurrent requests are to be made, it might be best to ensure that a connection exists using connectIfNotAlreadyConnected before making all the requests.

connectIfNotAlreadyConnected :: Http2Manager -> Target -> IO () Source #

Connects to a server if it is not already connected, useful when making many concurrent requests. This way the first few requests don't have to fight for making a connection This way the first few requests don't have to fight for making a connection.

disconnectTarget :: Http2Manager -> Target -> IO () Source #

Disconnects HTTP2 connection if there exists one. Will hang around until all the ongoing requests complete. This would throw an error if the background thread maintaining the connection throws an error, e.g. there was a TLS error or the connection was already disconnected with error.

disconnectTargetWithTimeout :: Http2Manager -> Target -> Int -> IO () Source #

Disconnects HTTP2 connection if there exists one. If the background thread running the connection does not finish within 1 second, it is canceled. Errors from the background thread running the connection are not propagated.

NOTE: Any requests in progress might not finish correctly.

startPersistentHTTP2Connection Source #

Arguments

:: SSLContext 
-> Target 
-> Int 
-> Bool 
-> Int

TCP connect timeout in microseconds

-> MVar ConnectionAction 
-> IO () 

sendRequestWithConnection :: HTTP2Conn -> Request -> (Response -> IO r) -> IO r Source #

Does not check whether connection is actually running. Users should use withHTTP2Request. This function is good for testing.