http2-client-0.10.0.1: A native HTTP2 client library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.HTTP2.Client.Helpers

Description

A toolbox with high-level functions to interact with an established HTTP2 conection.

These helpers make the assumption that you want to work in a multi-threaded environment and that you want to send and receiving whole HTTP requests at once (i.e., you do not care about streaming individual HTTP requests/responses but want to make many requests).

Synopsis

Sending and receiving HTTP body

upload Source #

Arguments

:: ByteString

HTTP body.

-> (FrameFlags -> FrameFlags)

Flag modifier for the last DATA frame sent.

-> Http2Client

The client.

-> OutgoingFlowControl

The outgoing flow control for this client. (We might remove this argument in the future because we can get it from the previous argument.

-> Http2Stream

The corresponding HTTP stream.

-> OutgoingFlowControl

The flow control for this stream.

-> ClientIO () 

Uploads a whole HTTP body at a time.

This function should be called at most once per stream. This function closes the stream with HTTP2.setEndStream chunk at the end. If you want to post data (e.g., streamed chunks) your way to avoid loading a whole bytestring in RAM, please study the source code of this function first.

This function sends one chunk at a time respecting by preference: - server's flow control desires - server's chunking preference

Uploading an empty bytestring will send a single DATA frame with setEndStream and no payload.

waitStream Source #

Arguments

:: Http2Client

The connection.

-> Http2Stream

The stream to wait on. This stream must be part of the connection.

-> IncomingFlowControl

Incoming flow control for the stream.

-> PushPromiseHandler 
-> ClientIO StreamResult 

Wait for a stream until completion.

This function is fine if you don't want to consume results in chunks. See fromStreamResult to collect the complicated StreamResult into a simpler StreamResponse.

fromStreamResult :: StreamResult -> Either ErrorCode StreamResponse Source #

Converts a StreamResult to a StramResponse, stopping at the first error using the `Either HTTP2.ErrorCode` monad.

type StreamResult = (Either ErrorCode HeaderList, [Either ErrorCode ByteString], Maybe HeaderList) Source #

Result containing the unpacked headers and all frames received in on a stream. See StreamResponse and fromStreamResult to get a higher-level utility.

type StreamResponse = (HeaderList, ByteString, Maybe HeaderList) Source #

An HTTP2 response, once fully received, is made of headers and a payload.

Diagnostics

ping Source #

Arguments

:: Http2Client

client connection

-> Int

timeout in microseconds

-> ByteString

8-bytes message to uniquely identify the reply

-> ClientIO PingReply 

Performs a ping and waits for a reply up to a given timeout (in microseconds).

data TimedOut Source #

Opaque type to express an action which timed out.

Instances

Instances details
Show TimedOut Source # 
Instance details

Defined in Network.HTTP2.Client.Helpers