http_types

Module trailers

Source
Expand description

HTTP trailing headers.

Trailing headers are headers that are send after the body payload has been sent. This is for example useful for sending integrity checks of streamed payloads that are computed on the fly.

The way trailing headers are sent over the wire varies per protocol. But in http-types we provide a Trailers struct that’s used to contain the headers.

To send trailing headers, see Request::{send_trailers, recv_trailers} and Response::{send_trailers, recv_trailers}.

§Example

use http_types::{Url, Method, Request, Trailers};
use http_types::headers::{HeaderName, HeaderValue};
use async_std::task;
use std::str::FromStr;

let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());

let sender = req.send_trailers();
let mut trailers = Trailers::new();
trailers.insert("Content-Type", "text/plain");

task::spawn(async move {
    let trailers = req.recv_trailers().await;
});

sender.send(trailers).await;

§See Also

Structs§

  • The receiving half of a channel to send trailers.
  • The sending half of a channel to send trailers.
  • A collection of trailing HTTP headers.