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

Create a new instance of WwwAuthenticate.

Create a new instance from headers.

Sets the header.

Get the HeaderName.

Get the HeaderValue.

Get the authorization scheme.

Set the authorization scheme.

Get the authorization realm.

Set the authorization realm.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.