From 5b740a7a2a50f049619797c9e4fcd7815fea259e Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 22 Sep 2018 22:24:45 +0200 Subject: Upgrade dep reqwest to 0.9.1. --- Cargo.toml | 2 +- src/client.rs | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8713632..4db95b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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) -- cgit v1.2.3