remove util submod

This commit is contained in:
Martin Algesten
2018-06-14 15:18:01 +02:00
parent 75c8a9bbde
commit f2c3f351ca
5 changed files with 25 additions and 32 deletions

View File

@@ -3,7 +3,6 @@ use std::str::FromStr;
use std::sync::Mutex;
use header::{add_header, Header};
use util::*;
// to get to share private fields
include!("request.rs");
@@ -270,6 +269,29 @@ impl Agent {
}
}
fn basic_auth(user: &str, pass: &str) -> String {
let safe = match user.find(":") {
Some(idx) => &user[..idx],
None => user,
};
::base64::encode(&format!("{}:{}", safe, pass))
}
fn mime_of<S: Into<String>>(s: S) -> String {
let s = s.into();
match &s[..] {
"json" => "application/json",
"form" => "application/x-www-form-urlencoded",
_ => match ::mime_guess::get_mime_type_str(&s) {
Some(mime) => mime,
None => "foo",
},
}.to_string()
}
#[cfg(test)]
mod tests {
use super::*;