Module body_image::client [] [src]

HTTP client integration and utilities.

This optional module (via non-default client feature) provides additional integration with the http crate and hyper 0.11.x (with the compat feature, and its other dependencies.). Thus far, its primary motivation has been to support the barc record command line, though some methods may have more general utility:

Starting with the significant expected changes for hyper 0.12 and its dependencies, the intent is to evolve this module into a more general purpose middleware type facility, including:

  • More flexible integration of the recorded Dialog into more complete hyper applications or downstream crate and frameworks.

  • Symmetric support for BodySink/BodyImage request bodies.

  • Asynchronous I/O adaptions for file-based bodies where appropriate and beneficial.

Structs

RequestRecord

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

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.

Traits

RequestRecordable

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 all the necesarry hyper and tokio components in a simplistic form internally, and is currently not recommended for anything but one-time use.

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.

user_agent

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