diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/client.rs | 17 |
2 files changed, 9 insertions, 10 deletions
@@ -20,7 +20,7 @@ version = "0.1.0" authors = ["haraldei"] [dependencies] -reqwest = "0.8" +reqwest = "0.9.1" serde = "1.0" serde_urlencoded = "0.5.1" diff --git a/src/client.rs b/src/client.rs index c724526..098c0ac 100644 --- a/src/client.rs +++ b/src/client.rs @@ -18,8 +18,7 @@ use error::Error; use item::ItemBuilder; use reqwest::{ self, - header::{Accept, ContentType, qitem}, - mime, + header::{ACCEPT, CONTENT_TYPE}, StatusCode, }; use serde::Serialize; @@ -82,13 +81,13 @@ impl Client { { let url = self.url(path, args); let mut res = self.inner.get(&url) - .header(Accept(vec![qitem(mime::APPLICATION_JSON)])) + .header(ACCEPT, "application/json") .basic_auth(self.user.clone(), Some(self.pw.clone())) .send()?; match res.status() { - StatusCode::Unauthorized => Err(Error::Unauthorized), - StatusCode::Ok => { + StatusCode::UNAUTHORIZED => Err(Error::Unauthorized), + StatusCode::OK => { let mut body = String::new(); res.read_to_string(&mut body)?; Ok(body) @@ -105,15 +104,15 @@ impl Client { { let url = self.url(path, &()); let mut res = self.inner.post(&url) - .header(Accept(vec![qitem(mime::APPLICATION_JSON)])) - .header(ContentType::form_url_encoded()) + .header(ACCEPT, "application/json") + .header(CONTENT_TYPE, "application/x-www-form-urlencoded") .basic_auth(self.user.clone(), Some(self.pw.clone())) .form(&data) .send()?; match res.status() { - StatusCode::Unauthorized => Err(Error::Unauthorized), - StatusCode::Ok => { + StatusCode::UNAUTHORIZED => Err(Error::Unauthorized), + StatusCode::OK => { let mut body = String::new(); res.read_to_string(&mut body)?; Ok(body) |