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 std::sync::Mutex;
|
||||||
|
|
||||||
use header::{add_header, Header};
|
use header::{add_header, Header};
|
||||||
use util::*;
|
|
||||||
|
|
||||||
// to get to share private fields
|
// to get to share private fields
|
||||||
include!("request.rs");
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ extern crate serde_json;
|
|||||||
extern crate native_tls;
|
extern crate native_tls;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
mod agent;
|
mod agent;
|
||||||
mod error;
|
mod error;
|
||||||
mod header;
|
mod header;
|
||||||
mod util;
|
mod macros;
|
||||||
|
mod serde_macros;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
#[allow(dead_code)]
|
|
||||||
mod macros;
|
|
||||||
mod serde_macros;
|
|
||||||
pub mod vecread;
|
|
||||||
|
|
||||||
use base64;
|
|
||||||
use mime_guess::get_mime_type_str;
|
|
||||||
|
|
||||||
pub use util::vecread::VecRead;
|
|
||||||
|
|
||||||
pub fn basic_auth(user: &str, pass: &str) -> String {
|
|
||||||
let safe = match user.find(":") {
|
|
||||||
Some(idx) => &user[..idx],
|
|
||||||
None => user,
|
|
||||||
};
|
|
||||||
base64::encode(&format!("{}:{}", safe, pass))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub 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 get_mime_type_str(&s) {
|
|
||||||
Some(mime) => mime,
|
|
||||||
None => "foo",
|
|
||||||
},
|
|
||||||
}.to_string()
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user