Struct http_types::content::accept_encoding::AcceptEncoding [−][src]
pub struct AcceptEncoding { /* fields omitted */ }
Expand description
Client header advertising available compression algorithms.
Specifications
Examples
use http_types::content::{AcceptEncoding, ContentEncoding, Encoding, EncodingProposal}; use http_types::Response; let mut accept = AcceptEncoding::new(); accept.push(EncodingProposal::new(Encoding::Brotli, Some(0.8))?); accept.push(EncodingProposal::new(Encoding::Gzip, Some(0.4))?); accept.push(EncodingProposal::new(Encoding::Identity, None)?); let mut res = Response::new(200); let encoding = accept.negotiate(&[Encoding::Brotli, Encoding::Gzip])?; encoding.apply(&mut res); assert_eq!(res["Content-Encoding"], "br");
Implementations
Create an instance of AcceptEncoding
from a Headers
instance.
Push a directive into the list of entries.
Set the wildcard directive.
Sort the header directives by weight.
Headers with a higher q=
value will be returned first. If two
directives have the same weight, the directive that was declared later
will be returned first.
Determine the most suitable Content-Encoding
encoding.
Errors
If no suitable encoding is found, an error with the status of 406
will be returned.
Get the HeaderName
.
Get the HeaderValue
.
An iterator visiting all entries.
Trait Implementations
type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
Converts this object to an iterator of resolved HeaderValues
.