fn parse_auth(auth: &[String], origin: &Url) -> Result<(String, Option<String>, String), String> {
    // Convert any empty strings to None
    let auth: Vec<Option<String>> = auth
        .iter()
        .map(|s| match s.as_ref() {
            "" => None,
            s => Some(s.to_string()),
        })
        .collect();

    // Match on auth values and origin host, defaulting to the origin host if host not provided
    match (auth.as_slice(), origin.host_str()) {
        ([Some(username)], Some(origin_host)) => {
            Ok((username.to_string(), None, origin_host.to_string()))
        }
        ([Some(username), password], Some(origin_host)) => Ok((
            username.to_string(),
            password.clone(),
            origin_host.to_string(),
        )),
        ([Some(username), password, None, ..], Some(origin_host)) => Ok((
            username.to_string(),
            password.clone(),
            origin_host.to_string(),
        )),
        ([Some(username), password, Some(host), ..], _) => {
            Ok((username.to_string(), password.clone(), host.to_string()))
        }
        _ => Err("Invalid arguments supplied to auth".to_string()),
    }
}
/// Parse HTTP authentication credentials from string iterable
Parse HTTP authentication credentials from string iterable
Parse HTTP authentication credentials from string iterable
fn parse_auth(auth: &[String], origin: &Url) -> Result<(String, Option<String>, String), String> {
    // Convert any empty strings to None
    let auth: Vec<Option<String>> = auth
        .iter()
        .map(|s| match s.as_ref() {
            "" => None,
            s => Some(s.to_string()),
        })
        .collect();
    // Match on auth values and origin host, defaulting to the origin host if host not provided
    match (auth.as_slice(), origin.host_str()) {
        ([Some(username)], Some(origin_host)) => {
            Ok((username.to_string(), None, origin_host.to_string()))
        }
        ([Some(username), password], Some(origin_host)) => Ok((
            username.to_string(),
            password.clone(),
            origin_host.to_string(),
        )),
        ([Some(username), password, None, ..], Some(origin_host)) => Ok((
            username.to_string(),
            password.clone(),
            origin_host.to_string(),
        )),
        ([Some(username), password, Some(host), ..], _) => {
            Ok((username.to_string(), password.clone(), host.to_string()))
        }
        _ => Err("Invalid arguments supplied to auth".to_string()),
    }
}
fn parse_auth ( auth : & [ String ] , origin : & Url ) -> Result < ( String , Option < String > , String ) , String > { // Convert any empty strings to None let auth : Vec < Option < String > > = auth . iter ( ) . map ( | s | match s . as_ref ( ) { " " => None , s => Some ( s . to_string ( ) ) , } ) . collect ( ) ; // Match on auth values and origin host, defaulting to the origin host if host not provided match ( auth . as_slice ( ) , origin . host_str ( ) ) { ( [ Some ( username ) ] , Some ( origin_host ) ) => { Ok ( ( username . to_string ( ) , None , origin_host . to_string ( ) ) ) } ( [ Some ( username ) , password ] , Some ( origin_host ) ) => Ok ( ( username . to_string ( ) , password . clone ( ) , origin_host . to_string ( ) , ) ) , ( [ Some ( username ) , password , None , .. ] , Some ( origin_host ) ) => Ok ( ( username . to_string ( ) , password . clone ( ) , origin_host . to_string ( ) , ) ) , ( [ Some ( username ) , password , Some ( host ) , .. ] , _ ) => { Ok ( ( username . to_string ( ) , password . clone ( ) , host . to_string ( ) ) ) } _ => Err ( " " . to_string ( ) ) , } }
Parse HTTP authentication credentials from string iterable
Parse HTTP authentication credentials from string iterable
auth
&[String]
origin
&Url
auth
&[String]
origin
&Url