pub struct PasswordClientBuilder(/* private fields */);
Expand description
Builds a PasswordClient
from the supplied challenges; create via
PasswordClient::builder
.
Often you can just use PasswordClient
’s TryFrom
implementations
to convert from a parsed challenge (crate::ChallengeRef
) or
unparsed challenges (str
, [http::header::HeaderValue
], or
[http::header::GetAll
]).
The builder allows more flexibility. For example, if you are using a HTTP
library which is not based on a http
crate, you might need to create
a PasswordClient
from an iterator over multiple WWW-Authenticate
headers. You can feed each to PasswordClientBuilder::challenges
.
Prefers Digest
over Basic
, consistent with the RFC 7235 section
2.1 advice
for a user-agent to pick the most secure auth-scheme it understands.
When there are multiple Digest
challenges, currently uses the first,
consistent with the RFC 7616 section
3.7
advice to “use the first challenge it supports, unless a local policy
dictates otherwise”. In the future, it may prioritize by algorithm.
Ignores parse errors as long as there’s at least one parseable, supported challenge.
§Example
Implementations§
source§impl PasswordClientBuilder
impl PasswordClientBuilder
sourcepub fn challenges(self, value: &str) -> Self
pub fn challenges(self, value: &str) -> Self
Considers all challenges from the given &str
challenge list.
sourcepub fn challenge(self, challenge: &ChallengeRef<'_>) -> Self
pub fn challenge(self, challenge: &ChallengeRef<'_>) -> Self
Considers a single challenge.
sourcepub fn build(self) -> Result<PasswordClient, String>
pub fn build(self) -> Result<PasswordClient, String>
Returns a new PasswordClient
or fails.