remove frivolous mime guessing dep
This commit is contained in:
12
src/agent.rs
12
src/agent.rs
@@ -332,18 +332,6 @@ fn basic_auth(user: &str, pass: &str) -> String {
|
||||
::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::*;
|
||||
|
||||
@@ -73,7 +73,6 @@ extern crate dns_lookup;
|
||||
extern crate encoding;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate mime_guess;
|
||||
extern crate native_tls;
|
||||
extern crate qstring;
|
||||
extern crate serde_json;
|
||||
|
||||
@@ -185,7 +185,7 @@ impl Request {
|
||||
///
|
||||
/// ```
|
||||
/// let r = ureq::post("/my_page")
|
||||
/// .content_type("text/plain")
|
||||
/// .set("Content-Type", "text/plain")
|
||||
/// .send_string("Hello World!");
|
||||
/// println!("{:?}", r);
|
||||
/// ```
|
||||
@@ -385,66 +385,6 @@ impl Request {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the `Content-Type` header.
|
||||
///
|
||||
/// The default is `application/json`.
|
||||
///
|
||||
/// As a short-hand the `.content_type()` method accepts the
|
||||
/// canonicalized MIME type name complete with
|
||||
/// type/subtype, or simply the extension name such as
|
||||
/// "xml", "json", "png".
|
||||
///
|
||||
/// These are all the same.
|
||||
///
|
||||
/// ```
|
||||
/// ureq::post("/my_page")
|
||||
/// .set("Content-Type", "text/plain")
|
||||
/// .call();
|
||||
///
|
||||
/// ureq::post("/my_page")
|
||||
/// .content_type("text/plain")
|
||||
/// .call();
|
||||
///
|
||||
/// ureq::post("/my_page")
|
||||
/// .content_type("txt")
|
||||
/// .call();
|
||||
/// ```
|
||||
pub fn content_type<S>(&mut self, c: S) -> &mut Request
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.set("Content-Type", mime_of(c))
|
||||
}
|
||||
|
||||
/// Sets the `Accept` header in the same way as `content_type()`.
|
||||
///
|
||||
/// The short-hand `.accept()` method accepts the
|
||||
/// canonicalized MIME type name complete with
|
||||
/// type/subtype, or simply the extension name such as
|
||||
/// "xml", "json", "png".
|
||||
///
|
||||
/// These are all the same.
|
||||
///
|
||||
/// ```
|
||||
/// ureq::get("/my_page")
|
||||
/// .set("Accept", "text/plain")
|
||||
/// .call();
|
||||
///
|
||||
/// ureq::get("/my_page")
|
||||
/// .accept("text/plain")
|
||||
/// .call();
|
||||
///
|
||||
/// ureq::get("/my_page")
|
||||
/// .accept("txt")
|
||||
/// .call();
|
||||
/// ```
|
||||
pub fn accept<S>(&mut self, accept: S) -> &mut Request
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.set("Accept", mime_of(accept))
|
||||
}
|
||||
|
||||
/// Timeout for the socket connection to be successful.
|
||||
///
|
||||
/// The default is `0`, which means a request can block forever.
|
||||
|
||||
Reference in New Issue
Block a user