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
impl WwwAuthenticate
pub fn new<C: Challenge>(c: C) -> Self
pub fn new_from_raw(scheme: String, raw: RawChallenge) -> Self
Sourcepub fn get<C: Challenge>(&self) -> Option<Vec<C>>
pub fn get<C: Challenge>(&self) -> Option<Vec<C>>
find challenges and convert them into C
if found.
Sourcepub fn get_raw(&self, name: &str) -> Option<&[RawChallenge]>
pub fn get_raw(&self, name: &str) -> Option<&[RawChallenge]>
find challenges and return it if found
Sourcepub fn set<C: Challenge>(&mut self, c: C) -> bool
pub fn set<C: Challenge>(&mut self, c: C) -> bool
set a challenge. This replaces existing challenges of the same name.
Sourcepub fn set_raw(&mut self, scheme: String, raw: RawChallenge) -> bool
pub fn set_raw(&mut self, scheme: String, raw: RawChallenge) -> bool
set a challenge. This replaces existing challenges of the same name.
Sourcepub fn append<C: Challenge>(&mut self, c: C)
pub fn append<C: Challenge>(&mut self, c: C)
append a challenge. This appends existing challenges of the same name.
Sourcepub fn append_raw(&mut self, scheme: String, raw: RawChallenge)
pub fn append_raw(&mut self, scheme: String, raw: RawChallenge)
append a challenge. This appends existing challenges of the same name.
Trait Implementations§
Source§impl Clone for WwwAuthenticate
impl Clone for WwwAuthenticate
Source§fn clone(&self) -> WwwAuthenticate
fn clone(&self) -> WwwAuthenticate
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for WwwAuthenticate
impl Debug for WwwAuthenticate
Source§impl Display for WwwAuthenticate
impl Display for WwwAuthenticate
Auto Trait Implementations§
impl Freeze for WwwAuthenticate
impl RefUnwindSafe for WwwAuthenticate
impl Send for WwwAuthenticate
impl Sync for WwwAuthenticate
impl Unpin for WwwAuthenticate
impl UnwindSafe for WwwAuthenticate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more