feat(headers): add TE header struct (#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 #1109 BREAKING CHANGE: The `Encoding` enum has an additional variant, `Trailers`.
This commit is contained in:
committed by
Sean McArthur
parent
414859978b
commit
f1859dfd7a
@@ -1,7 +1,7 @@
|
||||
use std::fmt;
|
||||
use std::str;
|
||||
|
||||
pub use self::Encoding::{Chunked, Brotli, Gzip, Deflate, Compress, Identity, EncodingExt};
|
||||
pub use self::Encoding::{Chunked, Brotli, Gzip, Deflate, Compress, Identity, EncodingExt, Trailers};
|
||||
|
||||
/// A value to represent an encoding used in `Transfer-Encoding`
|
||||
/// or `Accept-Encoding` header.
|
||||
@@ -19,6 +19,8 @@ pub enum Encoding {
|
||||
Compress,
|
||||
/// The `identity` encoding.
|
||||
Identity,
|
||||
/// The `trailers` encoding.
|
||||
Trailers,
|
||||
/// Some other encoding that is less common, can be any String.
|
||||
EncodingExt(String)
|
||||
}
|
||||
@@ -32,6 +34,7 @@ impl fmt::Display for Encoding {
|
||||
Deflate => "deflate",
|
||||
Compress => "compress",
|
||||
Identity => "identity",
|
||||
Trailers => "trailers",
|
||||
EncodingExt(ref s) => s.as_ref()
|
||||
})
|
||||
}
|
||||
@@ -47,6 +50,7 @@ impl str::FromStr for Encoding {
|
||||
"gzip" => Ok(Gzip),
|
||||
"compress" => Ok(Compress),
|
||||
"identity" => Ok(Identity),
|
||||
"trailers" => Ok(Trailers),
|
||||
_ => Ok(EncodingExt(s.to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user