headers/common/
te.rs

1use http::HeaderValue;
2
3use crate::util::FlatCsv;
4
5/// `TE` header, defined in
6/// [RFC7230](https://datatracker.ietf.org/doc/html/rfc7230#section-4.3)
7///
8/// As RFC7230 states, "The "TE" header field in a request indicates what transfer codings,
9/// besides chunked, the client is willing to accept in response, and
10/// whether or not the client is willing to accept trailer fields in a
11/// chunked transfer coding."
12///
13/// For HTTP/1.1 compliant clients `chunked` transfer codings are assumed to be acceptable and
14/// so should never appear in this header.
15///
16/// # ABNF
17///
18/// ```text
19/// TE        = "TE" ":" #( t-codings )
20/// t-codings = "trailers" | ( transfer-extension [ accept-params ] )
21/// ```
22///
23/// # Example values
24/// * `trailers`
25/// * `trailers, deflate;q=0.5`
26/// * ``
27///
28/// # Examples
29///
30#[derive(Clone, Debug, PartialEq)]
31pub struct Te(FlatCsv);
32
33derive_header! {
34    Te(_),
35    name: TE
36}
37
38impl Te {
39    /// Create a `TE: trailers` header.
40    pub fn trailers() -> Self {
41        Te(HeaderValue::from_static("trailers").into())
42    }
43}