pub fn parse_challenges<'a>(
value: &'a [u8],
limits: &Limits,
) -> Result<Challenges<'a>, ParseError>Expand description
Parses WWW-Authenticate or Proxy-Authenticate: #challenge.
A challenge’s own parameters are comma-separated too, so where one
challenge ends is decided element by element: a token followed by = is
a parameter of the current challenge; a token alone, or a token and
1*SP before a token68 or a parameter, starts a new one. A parameter
name may not repeat within one challenge (RFC 9110 section 11.2).
§Errors
ErrorKind::DuplicateParameter; ErrorKind::NotToken;
ErrorKind::ExpectedSeparator for a parameter before any challenge;
ErrorKind::TrailingData; the list and quoted-string errors.
§Examples
use parse_net::{auth, Limits};
let c = auth::parse_challenges(
b"Newauth realm=\"apps\", type=1, title=\"Login to \\\"apps\\\"\", Basic realm=\"simple\"",
&Limits::DEFAULT)?;
let all: Vec<_> = c.iter().collect();
assert_eq!(all.len(), 2);
assert!(all[0].param("type").is_some_and(|v| v.eq_bytes(b"1")));
assert!(all[1].scheme_is("basic"));