aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.rs17
1 files changed, 8 insertions, 9 deletions
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)