pub struct Authorization { /* private fields */ }
Expand description

Credentials to authenticate a user agent with a server.

Specifications

Examples

use http_types::Response;
use http_types::auth::{AuthenticationScheme, Authorization};

let scheme = AuthenticationScheme::Basic;
let credentials = "0xdeadbeef202020";
let authz = Authorization::new(scheme, credentials.into());

let mut res = Response::new(200);
authz.apply(&mut res);

let authz = Authorization::from_headers(res)?.unwrap();

assert_eq!(authz.scheme(), AuthenticationScheme::Basic);
assert_eq!(authz.credentials(), credentials);

Implementations

Create a new instance of Authorization.

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 credentials.

Set the authorization credentials.

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.