Struct actix_http::http::header::Accept [−][src]
Expand description
Accept
header, defined in RFC7231
The Accept
header field can be used by user agents to specify
response media types that are acceptable. Accept header fields can
be used to indicate that the request is specifically limited to a
small set of desired types, as in the case of a request for an
in-line image
ABNF
Accept = #( media-range [ accept-params ] ) media-range = ( "*/*" / ( type "/" "*" ) / ( type "/" subtype ) ) *( OWS ";" OWS parameter ) accept-params = weight *( accept-ext ) accept-ext = OWS ";" OWS token [ "=" ( token / quoted-string ) ]
Example values
audio/*; q=0.2, audio/basic
text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c
Examples
extern crate mime; use actix_http::Response; use actix_http::http::header::{Accept, qitem}; let mut builder = Response::Ok(); builder.set( Accept(vec![ qitem(mime::TEXT_HTML), ]) );
extern crate mime; use actix_http::Response; use actix_http::http::header::{Accept, qitem}; let mut builder = Response::Ok(); builder.set( Accept(vec![ qitem(mime::APPLICATION_JSON), ]) );
extern crate mime; use actix_http::Response; use actix_http::http::header::{Accept, QualityItem, q, qitem}; let mut builder = Response::Ok(); builder.set( Accept(vec![ qitem(mime::TEXT_HTML), qitem("application/xhtml+xml".parse().unwrap()), QualityItem::new( mime::TEXT_XML, q(900) ), qitem("image/webp".parse().unwrap()), QualityItem::new( mime::STAR_STAR, q(800) ), ]) );
Tuple Fields
0: Vec<QualityItem<Mime>>
Implementations
Returns a sorted list of mime types from highest to lowest preference, accounting for q-factor weighting and specificity.
Extracts the most preferable mime type, accounting for q-factor weighting.
If no q-factors are provided, the first mime type is chosen. Note that items without q-factors are given the maximum preference value.
Returns None
if contained list is empty.
Trait Implementations
Returns the name of the header field
Parse a header
type Error = InvalidHeaderValue
type Error = InvalidHeaderValue
The type returned in the event of a conversion error.
Try to convert value to a Header value.
Auto Trait Implementations
impl RefUnwindSafe for Accept
impl UnwindSafe for Accept
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self