pub struct BasicChallenge {
pub realm: String,
pub charset: String,
}Expand description
Builder for WWW-Authenticate: Basic challenge headers.
RFC 7617 Section 2.2: the Basic challenge contains a realm parameter
identifying the protection space, and an optional charset parameter
indicating the server’s preferred encoding for credentials.
§Example
let challenge = BasicChallenge::new("my-realm");
assert_eq!(challenge.to_header_value(), "Basic realm=\"my-realm\", charset=\"UTF-8\"");Fields§
§realm: StringThe realm string identifying the protection space.
RFC 7617 Section 2.2: the realm value is a case-sensitive string defined by the origin server. Clients use it to determine which stored credentials to send.
charset: StringThe charset parameter.
RFC 7617 Section 2.1: when present and set to “UTF-8”, it indicates the server supports UTF-8 encoded credentials. This is the only value defined by the RFC.
Implementations§
Source§impl BasicChallenge
impl BasicChallenge
Sourcepub fn new(realm: &str) -> Self
pub fn new(realm: &str) -> Self
Create a new Basic challenge with the given realm.
The charset defaults to "UTF-8" per RFC 7617 Section 2.1.
Sourcepub fn to_header_value(&self) -> String
pub fn to_header_value(&self) -> String
Format the challenge as a WWW-Authenticate header value.
RFC 7617 Section 2.2:
WWW-Authenticate: Basic realm="<realm>", charset="UTF-8"Trait Implementations§
Source§impl Clone for BasicChallenge
impl Clone for BasicChallenge
Source§fn clone(&self) -> BasicChallenge
fn clone(&self) -> BasicChallenge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more