[][src]Crate body_image_futio

Asynchronous HTTP integration for body-image.

The body-image-futio crate integrates the body-image crate with futures, http, hyper 0.12.x., and tokio crates for both client and server use.

  • Trait RequestRecorder extends http::request::Builder for recording a RequestRecord of varous body types, which can then be passed to request_dialog or fetch.

  • The fetch function runs a RequestRecord and returns a completed Dialog using a single-use client and runtime for request_dialog.

  • The request_dialog function returns a Future<Item=Dialog>, given a suitable hyper::Client reference and RequestRecord. This function is thus more composable for complete tokio applications.

  • AsyncBodySink adapts a BodySink for asynchronous input from a (e.g. hyper::Body) Stream.

  • AsyncBodyImage adapts a BodyImage for asynchronous output as a Stream and hyper::body::Payload.

  • Alternatively, UniBodySink and UniBodyImage offer zero-copy MemMap support, using the custom UniBodyBuf item buffer type (instead of the hyper::Chunk or Bytes).

  • The decode_res_body and associated functions will decompress any supported Transfer/Content-Encoding of the response body and update the Dialog accordingly.

Structs

AsyncBodyImage

Adaptor for BodyImage implementing the futures::Stream and hyper::body::Payload traits.

AsyncBodySink

Adaptor for BodySink implementing the futures::Sink trait. This allows a hyper::Body (hyper::Chunk item) stream to be forwarded (e.g. via futures::Stream::forward) to a BodySink, in a fully asynchronous fashion.

RequestRecord

An http::Request and recording. Note that other important getter methods for RequestRecord are found in trait implementation RequestRecorded.

UniBodyBuf

Provides zero-copy read access to both Bytes and Mmap memory regions. Implements bytes::Buf (mmap feature only).

UniBodyImage

Adaptor for BodyImage implementing the futures::Stream and hyper::body::Payload traits, using the custom UniBodyBuf item buffer type (instead of Bytes) for zero-copy MemMap support (mmap feature only).

UniBodySink

Adaptor for BodySink implementing the futures::Sink trait. This allows a Stream<Item=UniBodyBuf> to be forwarded (e.g. via futures::Stream::forward) to a BodySink, in a fully asynchronous fashion and with zero-copy MemMap support (mmap feature only).

Statics

ACCEPT_ENCODINGS

Appropriate value for the HTTP accept-encoding request header, including (br)otli when the brotli feature is configured.

BROWSE_ACCEPT

A browser-like HTTP accept request header value, with preference for hypertext.

VERSION

The crate version string.

Traits

RequestRecorder

Extension trait for http::request::Builder, to enable recording key portions of the request for the final Dialog.

Functions

decode_res_body

Decode the response body of the provided Dialog compressed with any supported Encoding, updated the dialog accordingly. The provided Tunables controls decompression buffer sizes and if the final BodyImage will be in Ram or FsRead. Returns Ok(true) if the response body was decoded, Ok(false) if no or unsupported encoding, or an error on failure.

decompress

Decompress the provided body of any supported compression Encoding, using Tunables for buffering and the final returned BodyImage. If the encoding is not supported (e.g. Chunked or Brotli, without the feature enabled), returns None.

fetch

Run an HTTP request to completion, returning the full Dialog. This function constructs a default tokio Runtime, hyper_tls::HttpsConnector, and hyper::Client in a simplistic form internally, waiting with timeout, and dropping these on completion.

find_chunked

Return true if the chunked Transfer-Encoding can be found in the headers.

find_encodings

Return a list of supported encodings from the headers Transfer-Encoding and Content-Encoding. The Chunked encoding will be the first value if found. At most one compression encoding will be the last value if found.

request_dialog

Given a suitable hyper::Client and RequestRecord, return a Future<Item=Dialog>. The provided Tunables governs timeout intervals (initial response and complete body) and if the response BodyImage will be in Ram or FsRead.

user_agent

Return a generic HTTP user-agent header value for the crate, with version