remove util submod
This commit is contained in:
24
src/agent.rs
24
src/agent.rs
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user