forked from hyperium/hyper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(headers): add
TE
header struct (hyperium#1150)
The `TE` header is used by a client to specify which transfer encodings other than `chunked` it will accept. It also specifies whether HTTP trailers are acceptable. This commit also adds a `Trailers` variant to the `hyper::header::shared::Encoding` enum. Closes hyperium#1109 BREAKING CHANGE: The `Encoding` enum has an additional variant, `Trailers`.
- Loading branch information
1 parent
67fac87
commit 51d3853
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use header::{Encoding, QualityItem}; | ||
|
||
header! { | ||
/// `TE` header, defined in | ||
/// [RFC7230](http://tools.ietf.org/html/rfc7230#section-4.3) | ||
/// | ||
/// As RFC7230 states, "The "TE" header field in a request indicates what transfer codings, | ||
/// besides chunked, the client is willing to accept in response, and | ||
/// whether or not the client is willing to accept trailer fields in a | ||
/// chunked transfer coding." | ||
/// | ||
/// For HTTP/1.1 compliant clients `chunked` transfer codings are assumed to be acceptable and | ||
/// so should never appear in this header. | ||
/// | ||
/// # ABNF | ||
/// ```plain | ||
/// TE = "TE" ":" #( t-codings ) | ||
/// t-codings = "trailers" | ( transfer-extension [ accept-params ] ) | ||
/// ``` | ||
/// | ||
/// # Example values | ||
/// * `trailers` | ||
/// * `trailers, deflate;q=0.5` | ||
/// * `` | ||
/// | ||
/// # Examples | ||
/// ``` | ||
/// use hyper::header::{Headers, TE, Encoding, qitem}; | ||
/// | ||
/// let mut headers = Headers::new(); | ||
/// headers.set( | ||
/// TE(vec![qitem(Encoding::Trailers)]) | ||
/// ); | ||
/// ``` | ||
/// ``` | ||
/// use hyper::header::{Headers, TE, Encoding, qitem}; | ||
/// | ||
/// let mut headers = Headers::new(); | ||
/// headers.set( | ||
/// TE(vec![ | ||
/// qitem(Encoding::Trailers), | ||
/// qitem(Encoding::Gzip), | ||
/// qitem(Encoding::Deflate), | ||
/// ]) | ||
/// ); | ||
/// ``` | ||
/// ``` | ||
/// use hyper::header::{Headers, TE, Encoding, QualityItem, Quality, qitem}; | ||
/// | ||
/// let mut headers = Headers::new(); | ||
/// headers.set( | ||
/// TE(vec![ | ||
/// qitem(Encoding::Trailers), | ||
/// QualityItem::new(Encoding::Gzip, Quality(600)), | ||
/// QualityItem::new(Encoding::EncodingExt("*".to_owned()), Quality(0)), | ||
/// ]) | ||
/// ); | ||
/// ``` | ||
(TE, "TE") => (QualityItem<Encoding>)* | ||
|
||
test_te { | ||
// From the RFC | ||
test_header!(test1, vec![b"trailers"]); | ||
test_header!(test2, vec![b"trailers, deflate;q=0.5"]); | ||
test_header!(test3, vec![b""]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters