Struct WwwAuthenticate

Source
pub struct WwwAuthenticate(/* private fields */);
Expand description

WWW-Authenticate header, defined in RFC7235

The WWW-Authenticate header field indicates the authentication scheme(s) and parameters applicable to the target resource. This MUST be contained in HTTP responses whose status is 401.

§ABNF

WWW-Authenticate = 1#challenge

§Example values

  • Basic realm="foo", charset="UTF-8"
  • Digest realm="http-auth@example.org", qop="auth, auth-int", algorithm=MD5, nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v", opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"

§Examples

let auth = WwwAuthenticate::new(
    DigestChallenge {
        realm: Some("http-auth@example.org".into()),
        qop: Some(vec![Qop::Auth, Qop::AuthInt]),
        algorithm: Some(Algorithm::Sha256),
        nonce: Some("7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v".into()),
        opaque: Some("FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"
                         .into()),
        domain: None,
        stale: None,
        userhash: None,
});
let mut headers = Headers::new();
headers.set(auth);
let auth = WwwAuthenticate::new(BasicChallenge{realm: "foo".into()});
let mut headers = Headers::new();
headers.set(auth);
let auth = headers.get::<WwwAuthenticate>().unwrap();
let basics = auth.get::<BasicChallenge>().unwrap();

Implementations§

Source§

impl WwwAuthenticate

Source

pub fn new<C: Challenge>(c: C) -> Self

Source

pub fn new_from_raw(scheme: String, raw: RawChallenge) -> Self

Source

pub fn get<C: Challenge>(&self) -> Option<Vec<C>>

find challenges and convert them into C if found.

Source

pub fn get_raw(&self, name: &str) -> Option<&[RawChallenge]>

find challenges and return it if found

Source

pub fn set<C: Challenge>(&mut self, c: C) -> bool

set a challenge. This replaces existing challenges of the same name.

Source

pub fn set_raw(&mut self, scheme: String, raw: RawChallenge) -> bool

set a challenge. This replaces existing challenges of the same name.

Source

pub fn append<C: Challenge>(&mut self, c: C)

append a challenge. This appends existing challenges of the same name.

Source

pub fn append_raw(&mut self, scheme: String, raw: RawChallenge)

append a challenge. This appends existing challenges of the same name.

Source

pub fn has<C: Challenge>(&self) -> bool

test if the challenge exists

Trait Implementations§

Source§

impl Clone for WwwAuthenticate

Source§

fn clone(&self) -> WwwAuthenticate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WwwAuthenticate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for WwwAuthenticate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Header for WwwAuthenticate

Source§

fn header_name() -> &'static str

Returns the name of the header field this belongs to. Read more
Source§

fn parse_header<'a, T>(raw: &'a T) -> Result<Self>
where T: RawLike<'a>,

Parse a header from a raw stream of bytes. Read more
Source§

fn fmt_header(&self, f: &mut Formatter<'_, '_>) -> Result

Format a header to outgoing stream. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.