Extract realm and service from a WWW-Authenticate: Bearer header.
(header: &str)
| 333 | |
| 334 | /// Extract realm and service from a WWW-Authenticate: Bearer header. |
| 335 | fn parse_www_authenticate(header: &str) -> (String, String) { |
| 336 | let mut realm = String::new(); |
| 337 | let mut service = String::new(); |
| 338 | |
| 339 | for part in header.split(',') { |
| 340 | let part = part.trim(); |
| 341 | if let Some(v) = part |
| 342 | .strip_prefix("Bearer realm=\"") |
| 343 | .or_else(|| part.strip_prefix("realm=\"")) |
| 344 | { |
| 345 | realm = v.trim_end_matches('"').to_string(); |
| 346 | } else if let Some(v) = part.strip_prefix("service=\"") { |
| 347 | service = v.trim_end_matches('"').to_string(); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | (realm, service) |
| 352 | } |
| 353 | |
| 354 | // ─── Helpers ──────────────────────────────────────────────────────────────── |
| 355 |
no outgoing calls