[−][src]Struct scrappy_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 scrappy_http::Response; use scrappy_http::http::header::{Accept, qitem}; let mut builder = Response::Ok(); builder.set( Accept(vec![ qitem(mime::TEXT_HTML), ]) );
extern crate mime; use scrappy_http::Response; use scrappy_http::http::header::{Accept, qitem}; let mut builder = Response::Ok(); builder.set( Accept(vec![ qitem(mime::APPLICATION_JSON), ]) );
extern crate mime; use scrappy_http::Response; use scrappy_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) ), ]) );
Methods
impl Accept
[src]
pub fn star() -> Accept
[src]
A constructor to easily create Accept: */*
.
pub fn json() -> Accept
[src]
A constructor to easily create Accept: application/json
.
pub fn text() -> Accept
[src]
A constructor to easily create Accept: text/*
.
pub fn image() -> Accept
[src]
A constructor to easily create Accept: image/*
.
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.
fn deref(&self) -> &Vec<QualityItem<Mime>>
[src]
impl DerefMut for Accept
[src]
impl Display for Accept
[src]
impl Header for Accept
[src]
fn name() -> HeaderName
[src]
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.
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[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.
fn to_owned(&self) -> T
[src]
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.
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.
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>,