Struct ajars_surf::surf::http::auth::WwwAuthenticate
[−]pub struct WwwAuthenticate { /* private fields */ }
Expand description
Define the authentication method that should be used to gain access to a resource.
Specifications
Implementation Notes
This implementation only encodes and parses a single authentication method, further authorization methods are ignored. It also always passes the utf-8 encoding flag.
Examples
use http_types::Response;
use http_types::auth::{AuthenticationScheme, WwwAuthenticate};
let scheme = AuthenticationScheme::Basic;
let realm = "Access to the staging site";
let authz = WwwAuthenticate::new(scheme, realm.into());
let mut res = Response::new(200);
authz.apply(&mut res);
let authz = WwwAuthenticate::from_headers(res)?.unwrap();
assert_eq!(authz.scheme(), AuthenticationScheme::Basic);
assert_eq!(authz.realm(), realm);
Implementations
impl WwwAuthenticate
impl WwwAuthenticate
pub fn new(scheme: AuthenticationScheme, realm: String) -> WwwAuthenticate
pub fn new(scheme: AuthenticationScheme, realm: String) -> WwwAuthenticate
Create a new instance of WwwAuthenticate
.
pub fn from_headers(
headers: impl AsRef<Headers>
) -> Result<Option<WwwAuthenticate>, Error>
pub fn from_headers(
headers: impl AsRef<Headers>
) -> Result<Option<WwwAuthenticate>, Error>
Create a new instance from headers.
pub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName
.
pub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue
.
pub fn scheme(&self) -> AuthenticationScheme
pub fn scheme(&self) -> AuthenticationScheme
Get the authorization scheme.
pub fn set_scheme(&mut self, scheme: AuthenticationScheme)
pub fn set_scheme(&mut self, scheme: AuthenticationScheme)
Set the authorization scheme.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for WwwAuthenticate
impl Send for WwwAuthenticate
impl Sync for WwwAuthenticate
impl Unpin for WwwAuthenticate
impl UnwindSafe for WwwAuthenticate
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more