[−][src]Struct actix_http::http::header::Accept
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) ), ]) );
Implementations
impl Accept
[src]
pub fn star() -> Accept
[src]
Construct Accept: */*
.
pub fn json() -> Accept
[src]
Construct Accept: application/json
.
pub fn text() -> Accept
[src]
Construct Accept: text/*
.
pub fn image() -> Accept
[src]
Construct Accept: image/*
.
pub fn html() -> Accept
[src]
Construct Accept: text/html
.
pub fn mime_precedence(&self) -> Vec<Mime>
[src]
Returns a sorted list of mime types from highest to lowest preference, accounting for q-factor weighting and specificity.
pub fn mime_preference(&self) -> Option<Mime>
[src]
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
impl Clone for Accept
[src]
impl Debug for Accept
[src]
impl Deref for Accept
[src]
type Target = Vec<QualityItem<Mime>>
The resulting type after dereferencing.
pub fn deref(&self) -> &Vec<QualityItem<Mime>>
[src]
impl DerefMut for Accept
[src]
impl Display for Accept
[src]
impl Header for Accept
[src]
pub fn name() -> HeaderName
[src]
pub fn parse<T>(msg: &T) -> Result<Self, ParseError> where
T: HttpMessage,
[src]
T: HttpMessage,
impl IntoHeaderValue for Accept
[src]
type Error = InvalidHeaderValue
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<HeaderValue, Self::Error>
[src]
impl PartialEq<Accept> for Accept
[src]
impl StructuralPartialEq for Accept
[src]
Auto Trait Implementations
impl RefUnwindSafe for Accept
impl Send for Accept
impl Sync for Accept
impl Unpin for Accept
impl UnwindSafe for Accept
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,