cargo fix --edition

This commit is contained in:
Daniel Eades
2019-08-07 18:07:35 +01:00
committed by Sean McArthur
parent c3b2a26c46
commit 86d9cbc66e
25 changed files with 163 additions and 163 deletions

View File

@@ -7,7 +7,7 @@ extern crate tokio;
use std::mem; use std::mem;
use std::io::{self, Cursor}; use std::io::{self, Cursor};
use futures::{Future, Stream}; use futures::{Future, Stream};
use reqwest::async::{Client, Decoder}; use reqwest::r#async::{Client, Decoder};
fn fetch() -> impl Future<Item=(), Error=()> { fn fetch() -> impl Future<Item=(), Error=()> {

View File

@@ -7,7 +7,7 @@ extern crate serde;
extern crate serde_json; extern crate serde_json;
use futures::Future; use futures::Future;
use reqwest::async::{Client, Response}; use reqwest::r#async::{Client, Response};
use serde::Deserialize; use serde::Deserialize;
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]

View File

@@ -13,7 +13,7 @@ use std::path::Path;
use bytes::Bytes; use bytes::Bytes;
use futures::{Async, Future, Poll, Stream}; use futures::{Async, Future, Poll, Stream};
use reqwest::async::{Client, Decoder}; use reqwest::r#async::{Client, Decoder};
use tokio::fs::File; use tokio::fs::File;
use tokio::io::AsyncRead; use tokio::io::AsyncRead;

View File

@@ -72,7 +72,7 @@ impl Body {
impl Stream for Body { impl Stream for Body {
type Item = Chunk; type Item = Chunk;
type Error = ::Error; type Error = crate::Error;
#[inline] #[inline]
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
@@ -80,10 +80,10 @@ impl Stream for Body {
Inner::Hyper { ref mut body, ref mut timeout } => { Inner::Hyper { ref mut body, ref mut timeout } => {
if let Some(ref mut timeout) = timeout { if let Some(ref mut timeout) = timeout {
if let Async::Ready(()) = try_!(timeout.poll()) { if let Async::Ready(()) = try_!(timeout.poll()) {
return Err(::error::timedout(None)); return Err(crate::error::timedout(None));
} }
} }
try_ready!(body.poll_data().map_err(::error::from)) try_ready!(body.poll_data().map_err(crate::error::from))
}, },
Inner::Reusable(ref mut bytes) => { Inner::Reusable(ref mut bytes) => {
return if bytes.is_empty() { return if bytes.is_empty() {

View File

@@ -5,7 +5,7 @@ use std::net::IpAddr;
use bytes::Bytes; use bytes::Bytes;
use futures::{Async, Future, Poll}; use futures::{Async, Future, Poll};
use header::{ use crate::header::{
Entry, Entry,
HeaderMap, HeaderMap,
HeaderValue, HeaderValue,
@@ -31,16 +31,16 @@ use tokio::{clock, timer::Delay};
use super::request::{Request, RequestBuilder}; use super::request::{Request, RequestBuilder};
use super::response::Response; use super::response::Response;
use connect::Connector; use crate::connect::Connector;
use into_url::{expect_uri, try_uri}; use crate::into_url::{expect_uri, try_uri};
use cookie; use crate::cookie;
use redirect::{self, RedirectPolicy, remove_sensitive_headers}; use crate::redirect::{self, RedirectPolicy, remove_sensitive_headers};
use {IntoUrl, Method, Proxy, StatusCode, Url}; use crate::{IntoUrl, Method, Proxy, StatusCode, Url};
use ::proxy::get_proxies; use crate::proxy::get_proxies;
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
use {Certificate, Identity}; use crate::{Certificate, Identity};
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
use ::tls::TlsBackend; use crate::tls::TlsBackend;
static DEFAULT_USER_AGENT: &'static str = static DEFAULT_USER_AGENT: &'static str =
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
@@ -133,7 +133,7 @@ impl ClientBuilder {
/// ///
/// This method fails if TLS backend cannot be initialized, or the resolver /// This method fails if TLS backend cannot be initialized, or the resolver
/// cannot load the system configuration. /// cannot load the system configuration.
pub fn build(self) -> ::Result<Client> { pub fn build(self) -> crate::Result<Client> {
let config = self.config; let config = self.config;
let proxies = Arc::new(config.proxies); let proxies = Arc::new(config.proxies);
@@ -545,7 +545,7 @@ impl Client {
/// ///
/// This method fails if there was an error while sending request, /// This method fails if there was an error while sending request,
/// redirect loop was detected or redirect limit was exhausted. /// redirect loop was detected or redirect limit was exhausted.
pub fn execute(&self, request: Request) -> impl Future<Item = Response, Error = ::Error> { pub fn execute(&self, request: Request) -> impl Future<Item = Response, Error = crate::Error> {
self.execute_request(request) self.execute_request(request)
} }
@@ -568,7 +568,7 @@ impl Client {
// Add cookies from the cookie store. // Add cookies from the cookie store.
if let Some(cookie_store_wrapper) = self.inner.cookie_store.as_ref() { if let Some(cookie_store_wrapper) = self.inner.cookie_store.as_ref() {
if headers.get(::header::COOKIE).is_none() { if headers.get(crate::header::COOKIE).is_none() {
let cookie_store = cookie_store_wrapper.read().unwrap(); let cookie_store = cookie_store_wrapper.read().unwrap();
add_cookie_header(&mut headers, &cookie_store, &url); add_cookie_header(&mut headers, &cookie_store, &url);
} }
@@ -695,7 +695,7 @@ pub(super) struct Pending {
enum PendingInner { enum PendingInner {
Request(PendingRequest), Request(PendingRequest),
Error(Option<::Error>), Error(Option<crate::Error>),
} }
struct PendingRequest { struct PendingRequest {
@@ -713,7 +713,7 @@ struct PendingRequest {
} }
impl Pending { impl Pending {
pub(super) fn new_err(err: ::Error) -> Pending { pub(super) fn new_err(err: crate::Error) -> Pending {
Pending { Pending {
inner: PendingInner::Error(Some(err)), inner: PendingInner::Error(Some(err)),
} }
@@ -722,7 +722,7 @@ impl Pending {
impl Future for Pending { impl Future for Pending {
type Item = Response; type Item = Response;
type Error = ::Error; type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match self.inner { match self.inner {
@@ -734,12 +734,12 @@ impl Future for Pending {
impl Future for PendingRequest { impl Future for PendingRequest {
type Item = Response; type Item = Response;
type Error = ::Error; type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
if let Some(ref mut delay) = self.timeout { if let Some(ref mut delay) = self.timeout {
if let Async::Ready(()) = try_!(delay.poll(), &self.url) { if let Async::Ready(()) = try_!(delay.poll(), &self.url) {
return Err(::error::timedout(Some(self.url.clone()))); return Err(crate::error::timedout(Some(self.url.clone())));
} }
} }
@@ -850,10 +850,10 @@ impl Future for PendingRequest {
debug!("redirect_policy disallowed redirection to '{}'", loc); debug!("redirect_policy disallowed redirection to '{}'", loc);
}, },
redirect::Action::LoopDetected => { redirect::Action::LoopDetected => {
return Err(::error::loop_detected(self.url.clone())); return Err(crate::error::loop_detected(self.url.clone()));
}, },
redirect::Action::TooManyRedirects => { redirect::Action::TooManyRedirects => {
return Err(::error::too_many_redirects(self.url.clone())); return Err(crate::error::too_many_redirects(self.url.clone()));
} }
} }
} }
@@ -903,7 +903,7 @@ fn add_cookie_header(headers: &mut HeaderMap, cookie_store: &cookie::CookieStore
.join("; "); .join("; ");
if !header.is_empty() { if !header.is_empty() {
headers.insert( headers.insert(
::header::COOKIE, crate::header::COOKIE,
HeaderValue::from_bytes(header.as_bytes()).unwrap() HeaderValue::from_bytes(header.as_bytes()).unwrap()
); );
} }

View File

@@ -32,7 +32,7 @@ use hyper::{HeaderMap};
use hyper::header::{CONTENT_ENCODING, CONTENT_LENGTH, TRANSFER_ENCODING}; use hyper::header::{CONTENT_ENCODING, CONTENT_LENGTH, TRANSFER_ENCODING};
use super::{Body, Chunk}; use super::{Body, Chunk};
use error; use crate::error;
const INIT_BUFFER_SIZE: usize = 8192; const INIT_BUFFER_SIZE: usize = 8192;

View File

@@ -199,7 +199,7 @@ impl Part {
} }
/// Tries to set the mime of this part. /// Tries to set the mime of this part.
pub fn mime_str(self, mime: &str) -> ::Result<Part> { pub fn mime_str(self, mime: &str) -> crate::Result<Part> {
Ok(self.mime(try_!(mime.parse()))) Ok(self.mime(try_!(mime.parse())))
} }

View File

@@ -10,9 +10,9 @@ use super::body::{Body};
use super::client::{Client, Pending}; use super::client::{Client, Pending};
use super::multipart; use super::multipart;
use super::response::Response; use super::response::Response;
use header::{CONTENT_LENGTH, CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue}; use crate::header::{CONTENT_LENGTH, CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue};
use http::HttpTryFrom; use http::HttpTryFrom;
use {Method, Url}; use crate::{Method, Url};
/// A request which can be executed with `Client::execute()`. /// A request which can be executed with `Client::execute()`.
pub struct Request { pub struct Request {
@@ -25,7 +25,7 @@ pub struct Request {
/// A builder to construct the properties of a `Request`. /// A builder to construct the properties of a `Request`.
pub struct RequestBuilder { pub struct RequestBuilder {
client: Client, client: Client,
request: ::Result<Request>, request: crate::Result<Request>,
} }
impl Request { impl Request {
@@ -94,7 +94,7 @@ impl Request {
} }
impl RequestBuilder { impl RequestBuilder {
pub(super) fn new(client: Client, request: ::Result<Request>) -> RequestBuilder { pub(super) fn new(client: Client, request: crate::Result<Request>) -> RequestBuilder {
RequestBuilder { RequestBuilder {
client, client,
request, request,
@@ -113,10 +113,10 @@ impl RequestBuilder {
Ok(key) => { Ok(key) => {
match <HeaderValue as HttpTryFrom<V>>::try_from(value) { match <HeaderValue as HttpTryFrom<V>>::try_from(value) {
Ok(value) => { req.headers_mut().append(key, value); } Ok(value) => { req.headers_mut().append(key, value); }
Err(e) => error = Some(::error::from(e.into())), Err(e) => error = Some(crate::error::from(e.into())),
} }
}, },
Err(e) => error = Some(::error::from(e.into())), Err(e) => error = Some(crate::error::from(e.into())),
}; };
} }
if let Some(err) = error { if let Some(err) = error {
@@ -128,7 +128,7 @@ impl RequestBuilder {
/// Add a set of Headers to the existing ones on this Request. /// Add a set of Headers to the existing ones on this Request.
/// ///
/// The headers will be merged in to any already set. /// The headers will be merged in to any already set.
pub fn headers(mut self, headers: ::header::HeaderMap) -> RequestBuilder { pub fn headers(mut self, headers: crate::header::HeaderMap) -> RequestBuilder {
if let Ok(ref mut req) = self.request { if let Ok(ref mut req) = self.request {
replace_headers(req.headers_mut(), headers); replace_headers(req.headers_mut(), headers);
} }
@@ -171,7 +171,7 @@ impl RequestBuilder {
None => format!("{}:", username) None => format!("{}:", username)
}; };
let header_value = format!("Basic {}", encode(&auth)); let header_value = format!("Basic {}", encode(&auth));
self.header(::header::AUTHORIZATION, &*header_value) self.header(crate::header::AUTHORIZATION, &*header_value)
} }
/// Enable HTTP bearer authentication. /// Enable HTTP bearer authentication.
@@ -180,7 +180,7 @@ impl RequestBuilder {
T: fmt::Display, T: fmt::Display,
{ {
let header_value = format!("Bearer {}", token); let header_value = format!("Bearer {}", token);
self.header(::header::AUTHORIZATION, &*header_value) self.header(crate::header::AUTHORIZATION, &*header_value)
} }
/// Set the request body. /// Set the request body.
@@ -264,7 +264,7 @@ impl RequestBuilder {
let serializer = serde_urlencoded::Serializer::new(&mut pairs); let serializer = serde_urlencoded::Serializer::new(&mut pairs);
if let Err(err) = query.serialize(serializer) { if let Err(err) = query.serialize(serializer) {
error = Some(::error::from(err)); error = Some(crate::error::from(err));
} }
} }
if let Ok(ref mut req) = self.request { if let Ok(ref mut req) = self.request {
@@ -290,7 +290,7 @@ impl RequestBuilder {
); );
*req.body_mut() = Some(body.into()); *req.body_mut() = Some(body.into());
}, },
Err(err) => error = Some(::error::from(err)), Err(err) => error = Some(crate::error::from(err)),
} }
} }
if let Some(err) = error { if let Some(err) = error {
@@ -316,7 +316,7 @@ impl RequestBuilder {
); );
*req.body_mut() = Some(body.into()); *req.body_mut() = Some(body.into());
}, },
Err(err) => error = Some(::error::from(err)), Err(err) => error = Some(crate::error::from(err)),
} }
} }
if let Some(err) = error { if let Some(err) = error {
@@ -327,7 +327,7 @@ impl RequestBuilder {
/// Build a `Request`, which can be inspected, modified and executed with /// Build a `Request`, which can be inspected, modified and executed with
/// `Client::execute()`. /// `Client::execute()`.
pub fn build(self) -> ::Result<Request> { pub fn build(self) -> crate::Result<Request> {
self.request self.request
} }
@@ -358,7 +358,7 @@ impl RequestBuilder {
/// rt.block_on(response) /// rt.block_on(response)
/// # } /// # }
/// ``` /// ```
pub fn send(self) -> impl Future<Item = Response, Error = ::Error> { pub fn send(self) -> impl Future<Item = Response, Error = crate::Error> {
match self.request { match self.request {
Ok(req) => self.client.execute_request(req), Ok(req) => self.client.execute_request(req),
Err(err) => Pending::new_err(err), Err(err) => Pending::new_err(err),

View File

@@ -18,7 +18,7 @@ use serde_json;
use url::Url; use url::Url;
use cookie; use crate::cookie;
use super::Decoder; use super::Decoder;
use super::body::Body; use super::body::Body;
@@ -139,14 +139,14 @@ impl Response {
} }
/// Get the response text /// Get the response text
pub fn text(&mut self) -> impl Future<Item = String, Error = ::Error> { pub fn text(&mut self) -> impl Future<Item = String, Error = crate::Error> {
self.text_with_charset("utf-8") self.text_with_charset("utf-8")
} }
/// Get the response text given a specific encoding /// Get the response text given a specific encoding
pub fn text_with_charset(&mut self, default_encoding: &str) -> impl Future<Item = String, Error = ::Error> { pub fn text_with_charset(&mut self, default_encoding: &str) -> impl Future<Item = String, Error = crate::Error> {
let body = mem::replace(&mut self.body, Decoder::empty()); let body = mem::replace(&mut self.body, Decoder::empty());
let content_type = self.headers.get(::header::CONTENT_TYPE) let content_type = self.headers.get(crate::header::CONTENT_TYPE)
.and_then(|value| { .and_then(|value| {
value.to_str().ok() value.to_str().ok()
}) })
@@ -170,7 +170,7 @@ impl Response {
/// Try to deserialize the response body as JSON using `serde`. /// Try to deserialize the response body as JSON using `serde`.
#[inline] #[inline]
pub fn json<T: DeserializeOwned>(&mut self) -> impl Future<Item = T, Error = ::Error> { pub fn json<T: DeserializeOwned>(&mut self) -> impl Future<Item = T, Error = crate::Error> {
let body = mem::replace(&mut self.body, Decoder::empty()); let body = mem::replace(&mut self.body, Decoder::empty());
Json { Json {
@@ -201,9 +201,9 @@ impl Response {
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
#[inline] #[inline]
pub fn error_for_status(self) -> ::Result<Self> { pub fn error_for_status(self) -> crate::Result<Self> {
if self.status.is_client_error() || self.status.is_server_error() { if self.status.is_client_error() || self.status.is_server_error() {
Err(::error::status_code(*self.url, self.status)) Err(crate::error::status_code(*self.url, self.status))
} else { } else {
Ok(self) Ok(self)
} }
@@ -231,9 +231,9 @@ impl Response {
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
#[inline] #[inline]
pub fn error_for_status_ref(&self) -> ::Result<&Self> { pub fn error_for_status_ref(&self) -> crate::Result<&Self> {
if self.status.is_client_error() || self.status.is_server_error() { if self.status.is_client_error() || self.status.is_server_error() {
Err(::error::status_code(*self.url.clone(), self.status)) Err(crate::error::status_code(*self.url.clone(), self.status))
} else { } else {
Ok(self) Ok(self)
} }
@@ -278,7 +278,7 @@ struct Json<T> {
impl<T: DeserializeOwned> Future for Json<T> { impl<T: DeserializeOwned> Future for Json<T> {
type Item = T; type Item = T;
type Error = ::Error; type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let bytes = try_ready!(self.concat.poll()); let bytes = try_ready!(self.concat.poll());
let t = try_!(serde_json::from_slice(&bytes)); let t = try_!(serde_json::from_slice(&bytes));
@@ -301,7 +301,7 @@ struct Text {
impl Future for Text { impl Future for Text {
type Item = String; type Item = String;
type Error = ::Error; type Error = crate::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let bytes = try_ready!(self.concat.poll()); let bytes = try_ready!(self.concat.poll());
// a block because of borrow checker // a block because of borrow checker

View File

@@ -6,7 +6,7 @@ use bytes::Bytes;
use futures::Future; use futures::Future;
use hyper::{self}; use hyper::{self};
use {async_impl}; use crate::{async_impl};
/// The body of a `Request`. /// The body of a `Request`.
/// ///
@@ -218,7 +218,7 @@ pub(crate) struct Sender {
impl Sender { impl Sender {
// A `Future` that may do blocking read calls. // A `Future` that may do blocking read calls.
// As a `Future`, this integrates easily with `wait::timeout`. // As a `Future`, this integrates easily with `wait::timeout`.
pub(crate) fn send(self) -> impl Future<Item=(), Error=::Error> { pub(crate) fn send(self) -> impl Future<Item=(), Error=crate::Error> {
use std::cmp; use std::cmp;
use bytes::{BufMut, BytesMut}; use bytes::{BufMut, BytesMut};
use futures::future; use futures::future;
@@ -270,7 +270,7 @@ impl Sender {
.take() .take()
.expect("tx only taken on error") .expect("tx only taken on error")
.abort(); .abort();
return Err(::error::from(ret)); return Err(crate::error::from(ret));
} }
} }
} }
@@ -281,12 +281,12 @@ impl Sender {
.as_mut() .as_mut()
.expect("tx only taken on error") .expect("tx only taken on error")
.poll_ready() .poll_ready()
.map_err(::error::from)); .map_err(crate::error::from));
written += buf.len() as u64; written += buf.len() as u64;
let tx = tx.as_mut().expect("tx only taken on error"); let tx = tx.as_mut().expect("tx only taken on error");
if let Err(_) = tx.send_data(buf.take().freeze().into()) { if let Err(_) = tx.send_data(buf.take().freeze().into()) {
return Err(::error::timedout(None)); return Err(crate::error::timedout(None));
} }
}) })
} }

View File

@@ -8,11 +8,11 @@ use futures::{Async, Future, Stream};
use futures::future::{self, Either}; use futures::future::{self, Either};
use futures::sync::{mpsc, oneshot}; use futures::sync::{mpsc, oneshot};
use request::{Request, RequestBuilder}; use crate::request::{Request, RequestBuilder};
use response::Response; use crate::response::Response;
use {async_impl, header, Method, IntoUrl, Proxy, RedirectPolicy, wait}; use crate::{async_impl, header, Method, IntoUrl, Proxy, RedirectPolicy, wait};
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
use {Certificate, Identity}; use crate::{Certificate, Identity};
/// A `Client` to make Requests with. /// A `Client` to make Requests with.
/// ///
@@ -78,7 +78,7 @@ impl ClientBuilder {
/// ///
/// This method fails if TLS backend cannot be initialized, or the resolver /// This method fails if TLS backend cannot be initialized, or the resolver
/// cannot load the system configuration. /// cannot load the system configuration.
pub fn build(self) -> ::Result<Client> { pub fn build(self) -> crate::Result<Client> {
ClientHandle::new(self).map(|handle| Client { ClientHandle::new(self).map(|handle| Client {
inner: handle, inner: handle,
}) })
@@ -502,7 +502,7 @@ impl Client {
/// ///
/// This method fails if there was an error while sending request, /// This method fails if there was an error while sending request,
/// redirect loop was detected or redirect limit was exhausted. /// redirect loop was detected or redirect limit was exhausted.
pub fn execute(&self, request: Request) -> ::Result<Response> { pub fn execute(&self, request: Request) -> crate::Result<Response> {
self.inner.execute_request(request) self.inner.execute_request(request)
} }
} }
@@ -530,7 +530,7 @@ struct ClientHandle {
inner: Arc<InnerClientHandle> inner: Arc<InnerClientHandle>
} }
type ThreadSender = mpsc::UnboundedSender<(async_impl::Request, oneshot::Sender<::Result<async_impl::Response>>)>; type ThreadSender = mpsc::UnboundedSender<(async_impl::Request, oneshot::Sender<crate::Result<async_impl::Response>>)>;
struct InnerClientHandle { struct InnerClientHandle {
tx: Option<ThreadSender>, tx: Option<ThreadSender>,
@@ -545,11 +545,11 @@ impl Drop for InnerClientHandle {
} }
impl ClientHandle { impl ClientHandle {
fn new(builder: ClientBuilder) -> ::Result<ClientHandle> { fn new(builder: ClientBuilder) -> crate::Result<ClientHandle> {
let timeout = builder.timeout; let timeout = builder.timeout;
let builder = builder.inner; let builder = builder.inner;
let (tx, rx) = mpsc::unbounded(); let (tx, rx) = mpsc::unbounded();
let (spawn_tx, spawn_rx) = oneshot::channel::<::Result<()>>(); let (spawn_tx, spawn_rx) = oneshot::channel::<crate::Result<()>>();
let handle = try_!(thread::Builder::new().name("reqwest-internal-sync-runtime".into()).spawn(move || { let handle = try_!(thread::Builder::new().name("reqwest-internal-sync-runtime".into()).spawn(move || {
use tokio::runtime::current_thread::Runtime; use tokio::runtime::current_thread::Runtime;
@@ -573,7 +573,7 @@ impl ClientHandle {
}; };
let work = rx.for_each(move |(req, tx)| { let work = rx.for_each(move |(req, tx)| {
let mut tx_opt: Option<oneshot::Sender<::Result<async_impl::Response>>> = Some(tx); let mut tx_opt: Option<oneshot::Sender<crate::Result<async_impl::Response>>> = Some(tx);
let mut res_fut = client.execute(req); let mut res_fut = client.execute(req);
let task = future::poll_fn(move || { let task = future::poll_fn(move || {
@@ -631,7 +631,7 @@ impl ClientHandle {
}) })
} }
fn execute_request(&self, req: Request) -> ::Result<Response> { fn execute_request(&self, req: Request) -> crate::Result<Response> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let (req, body) = req.into_async(); let (req, body) = req.into_async();
let url = req.url().clone(); let url = req.url().clone();
@@ -654,9 +654,9 @@ impl ClientHandle {
let res = match wait::timeout(fut, self.timeout.0) { let res = match wait::timeout(fut, self.timeout.0) {
Ok(res) => res, Ok(res) => res,
Err(wait::Waited::TimedOut) => return Err(::error::timedout(Some(url))), Err(wait::Waited::TimedOut) => return Err(crate::error::timedout(Some(url))),
Err(wait::Waited::Executor(err)) => { Err(wait::Waited::Executor(err)) => {
return Err(::error::from(err).with_url(url)) return Err(crate::error::from(err).with_url(url))
}, },
Err(wait::Waited::Inner(err)) => { Err(wait::Waited::Inner(err)) => {
return Err(err.with_url(url)); return Err(err.with_url(url));

View File

@@ -19,7 +19,7 @@ use std::time::Duration;
#[cfg(feature = "trust-dns")] #[cfg(feature = "trust-dns")]
use dns::TrustDnsResolver; use dns::TrustDnsResolver;
use proxy::{Proxy, ProxyScheme}; use crate::proxy::{Proxy, ProxyScheme};
#[cfg(feature = "trust-dns")] #[cfg(feature = "trust-dns")]
type HttpConnector = ::hyper::client::HttpConnector<TrustDnsResolver>; type HttpConnector = ::hyper::client::HttpConnector<TrustDnsResolver>;
@@ -70,7 +70,7 @@ impl Connector {
tls: TlsConnectorBuilder, tls: TlsConnectorBuilder,
proxies: Arc<Vec<Proxy>>, proxies: Arc<Vec<Proxy>>,
local_addr: T, local_addr: T,
nodelay: bool) -> ::Result<Connector> nodelay: bool) -> crate::Result<Connector>
where where
T: Into<Option<IpAddr>>, T: Into<Option<IpAddr>>,
{ {
@@ -204,7 +204,7 @@ fn http_connector() -> ::Result<HttpConnector> {
} }
#[cfg(not(feature = "trust-dns"))] #[cfg(not(feature = "trust-dns"))]
fn http_connector() -> ::Result<HttpConnector> { fn http_connector() -> crate::Result<HttpConnector> {
Ok(HttpConnector::new(4)) Ok(HttpConnector::new(4))
} }
@@ -697,7 +697,7 @@ mod tests {
use tokio::runtime::current_thread::Runtime; use tokio::runtime::current_thread::Runtime;
use self::tokio_tcp::TcpStream; use self::tokio_tcp::TcpStream;
use super::tunnel; use super::tunnel;
use proxy; use crate::proxy;
static TUNNEL_OK: &'static [u8] = b"\ static TUNNEL_OK: &'static [u8] = b"\
HTTP/1.1 200 OK\r\n\ HTTP/1.1 200 OK\r\n\

View File

@@ -1,7 +1,7 @@
//! The cookies module contains types for working with request and response cookies. //! The cookies module contains types for working with request and response cookies.
use cookie_crate; use crate::cookie_crate;
use header; use crate::header;
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt; use std::fmt;
use std::time::SystemTime; use std::time::SystemTime;
@@ -55,7 +55,7 @@ impl Cookie<'static> {
} }
impl<'a> Cookie<'a> { impl<'a> Cookie<'a> {
fn parse(value: &'a ::header::HeaderValue) -> Result<Cookie<'a>, CookieParseError> { fn parse(value: &'a crate::header::HeaderValue) -> Result<Cookie<'a>, CookieParseError> {
std::str::from_utf8(value.as_bytes()) std::str::from_utf8(value.as_bytes())
.map_err(cookie::ParseError::from) .map_err(cookie::ParseError::from)
.and_then(cookie::Cookie::parse) .and_then(cookie::Cookie::parse)

View File

@@ -4,7 +4,7 @@ use std::io;
use tokio_executor::EnterError; use tokio_executor::EnterError;
use {StatusCode, Url}; use crate::{StatusCode, Url};
/// The Errors that may occur when processing a `Request`. /// The Errors that may occur when processing a `Request`.
/// ///
@@ -253,8 +253,8 @@ static BLOCK_IN_FUTURE: &'static str = "blocking Client used inside a Future con
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(ref url) = self.inner.url { if let Some(ref url) = self.inner.url {
try!(fmt::Display::fmt(url, f)); r#try!(fmt::Display::fmt(url, f));
try!(f.write_str(": ")); r#try!(f.write_str(": "));
} }
match self.inner.kind { match self.inner.kind {
Kind::Http(ref e) => fmt::Display::fmt(e, f), Kind::Http(ref e) => fmt::Display::fmt(e, f),
@@ -477,13 +477,13 @@ impl From<::rustls::TLSError> for Kind {
} }
} }
impl<T> From<::wait::Waited<T>> for Kind impl<T> From<crate::wait::Waited<T>> for Kind
where T: Into<Kind> { where T: Into<Kind> {
fn from(err: ::wait::Waited<T>) -> Kind { fn from(err: crate::wait::Waited<T>) -> Kind {
match err { match err {
::wait::Waited::TimedOut => io_timeout().into(), crate::wait::Waited::TimedOut => io_timeout().into(),
::wait::Waited::Executor(e) => e.into(), crate::wait::Waited::Executor(e) => e.into(),
::wait::Waited::Inner(e) => e.into(), crate::wait::Waited::Inner(e) => e.into(),
} }
} }
} }
@@ -558,7 +558,7 @@ macro_rules! try_ {
match $e { match $e {
Ok(v) => v, Ok(v) => v,
Err(err) => { Err(err) => {
return Err(::error::from(err)); return Err(crate::error::from(err));
} }
} }
); );
@@ -566,7 +566,7 @@ macro_rules! try_ {
match $e { match $e {
Ok(v) => v, Ok(v) => v,
Err(err) => { Err(err) => {
return Err(::Error::from(::error::InternalFrom(err, Some($url.clone())))); return Err(crate::Error::from(crate::error::InternalFrom(err, Some($url.clone()))));
} }
} }
) )
@@ -580,7 +580,7 @@ macro_rules! try_io {
return Ok(::futures::Async::NotReady); return Ok(::futures::Async::NotReady);
} }
Err(err) => { Err(err) => {
return Err(::error::from_io(err)); return Err(crate::error::from_io(err));
} }
} }
) )

View File

@@ -12,28 +12,28 @@ impl<T: PolyfillTryInto> IntoUrl for T {}
pub trait PolyfillTryInto { pub trait PolyfillTryInto {
// Besides parsing as a valid `Url`, the `Url` must be a valid // Besides parsing as a valid `Url`, the `Url` must be a valid
// `http::Uri`, in that it makes sense to use in a network request. // `http::Uri`, in that it makes sense to use in a network request.
fn into_url(self) -> ::Result<Url>; fn into_url(self) -> crate::Result<Url>;
} }
impl PolyfillTryInto for Url { impl PolyfillTryInto for Url {
fn into_url(self) -> ::Result<Url> { fn into_url(self) -> crate::Result<Url> {
if self.has_host() { if self.has_host() {
Ok(self) Ok(self)
} else { } else {
Err(::error::url_bad_scheme(self)) Err(crate::error::url_bad_scheme(self))
} }
} }
} }
impl<'a> PolyfillTryInto for &'a str { impl<'a> PolyfillTryInto for &'a str {
fn into_url(self) -> ::Result<Url> { fn into_url(self) -> crate::Result<Url> {
try_!(Url::parse(self)) try_!(Url::parse(self))
.into_url() .into_url()
} }
} }
impl<'a> PolyfillTryInto for &'a String { impl<'a> PolyfillTryInto for &'a String {
fn into_url(self) -> ::Result<Url> { fn into_url(self) -> crate::Result<Url> {
(&**self).into_url() (&**self).into_url()
} }
} }

View File

@@ -267,8 +267,8 @@ mod wait;
pub mod multipart; pub mod multipart;
/// An 'async' implementation of the reqwest `Client`. /// An 'async' implementation of the reqwest `Client`.
pub mod async { pub mod r#async {
pub use ::async_impl::{ pub use crate::async_impl::{
Body, Body,
Chunk, Chunk,
Decoder, Decoder,
@@ -311,7 +311,7 @@ pub mod async {
/// - there was an error while sending request /// - there was an error while sending request
/// - redirect loop was detected /// - redirect loop was detected
/// - redirect limit was exhausted /// - redirect limit was exhausted
pub fn get<T: IntoUrl>(url: T) -> ::Result<Response> { pub fn get<T: IntoUrl>(url: T) -> crate::Result<Response> {
Client::builder() Client::builder()
.build()? .build()?
.get(url) .get(url)

View File

@@ -44,8 +44,8 @@ use std::path::Path;
use mime_guess::{self, Mime}; use mime_guess::{self, Mime};
use async_impl::multipart::{FormParts, PartMetadata, PartProps}; use crate::async_impl::multipart::{FormParts, PartMetadata, PartProps};
use {Body}; use crate::{Body};
/// A multipart/form-data request. /// A multipart/form-data request.
pub struct Form { pub struct Form {
@@ -233,7 +233,7 @@ impl Part {
} }
/// Tries to set the mime of this part. /// Tries to set the mime of this part.
pub fn mime_str(self, mime: &str) -> ::Result<Part> { pub fn mime_str(self, mime: &str) -> crate::Result<Part> {
Ok(self.mime(try_!(mime.parse()))) Ok(self.mime(try_!(mime.parse())))
} }

View File

@@ -6,7 +6,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
use http::{header::HeaderValue, Uri}; use http::{header::HeaderValue, Uri};
use hyper::client::connect::Destination; use hyper::client::connect::Destination;
use url::percent_encoding::percent_decode; use url::percent_encoding::percent_decode;
use {IntoUrl, Url}; use crate::{IntoUrl, Url};
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
@@ -66,17 +66,17 @@ pub enum ProxyScheme {
/// parsing from a URL-like type, whilst also supporting proxy schemes /// parsing from a URL-like type, whilst also supporting proxy schemes
/// built directly using the factory methods. /// built directly using the factory methods.
pub trait IntoProxyScheme { pub trait IntoProxyScheme {
fn into_proxy_scheme(self) -> ::Result<ProxyScheme>; fn into_proxy_scheme(self) -> crate::Result<ProxyScheme>;
} }
impl<T: IntoUrl> IntoProxyScheme for T { impl<T: IntoUrl> IntoProxyScheme for T {
fn into_proxy_scheme(self) -> ::Result<ProxyScheme> { fn into_proxy_scheme(self) -> crate::Result<ProxyScheme> {
ProxyScheme::parse(self.into_url()?) ProxyScheme::parse(self.into_url()?)
} }
} }
impl IntoProxyScheme for ProxyScheme { impl IntoProxyScheme for ProxyScheme {
fn into_proxy_scheme(self) -> ::Result<ProxyScheme> { fn into_proxy_scheme(self) -> crate::Result<ProxyScheme> {
Ok(self) Ok(self)
} }
} }
@@ -96,7 +96,7 @@ impl Proxy {
/// # } /// # }
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
pub fn http<U: IntoProxyScheme>(proxy_scheme: U) -> ::Result<Proxy> { pub fn http<U: IntoProxyScheme>(proxy_scheme: U) -> crate::Result<Proxy> {
Ok(Proxy::new(Intercept::Http( Ok(Proxy::new(Intercept::Http(
proxy_scheme.into_proxy_scheme()? proxy_scheme.into_proxy_scheme()?
))) )))
@@ -116,7 +116,7 @@ impl Proxy {
/// # } /// # }
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
pub fn https<U: IntoProxyScheme>(proxy_scheme: U) -> ::Result<Proxy> { pub fn https<U: IntoProxyScheme>(proxy_scheme: U) -> crate::Result<Proxy> {
Ok(Proxy::new(Intercept::Https( Ok(Proxy::new(Intercept::Https(
proxy_scheme.into_proxy_scheme()? proxy_scheme.into_proxy_scheme()?
))) )))
@@ -136,7 +136,7 @@ impl Proxy {
/// # } /// # }
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
pub fn all<U: IntoProxyScheme>(proxy_scheme: U) -> ::Result<Proxy> { pub fn all<U: IntoProxyScheme>(proxy_scheme: U) -> crate::Result<Proxy> {
Ok(Proxy::new(Intercept::All( Ok(Proxy::new(Intercept::All(
proxy_scheme.into_proxy_scheme()? proxy_scheme.into_proxy_scheme()?
))) )))
@@ -266,10 +266,10 @@ impl ProxyScheme {
// To start conservative, keep builders private for now. // To start conservative, keep builders private for now.
/// Proxy traffic via the specified URL over HTTP /// Proxy traffic via the specified URL over HTTP
fn http<T: IntoUrl>(url: T) -> ::Result<Self> { fn http<T: IntoUrl>(url: T) -> crate::Result<Self> {
Ok(ProxyScheme::Http { Ok(ProxyScheme::Http {
auth: None, auth: None,
uri: ::into_url::expect_uri(&url.into_url()?), uri: crate::into_url::expect_uri(&url.into_url()?),
}) })
} }
@@ -326,7 +326,7 @@ impl ProxyScheme {
/// ///
/// Supported schemes: HTTP, HTTPS, (SOCKS5, SOCKS5H if `socks` feature is enabled). /// Supported schemes: HTTP, HTTPS, (SOCKS5, SOCKS5H if `socks` feature is enabled).
// Private for now... // Private for now...
fn parse(url: Url) -> ::Result<Self> { fn parse(url: Url) -> crate::Result<Self> {
// Resolve URL to a host and port // Resolve URL to a host and port
#[cfg(feature = "socks")] #[cfg(feature = "socks")]
let to_addr = || { let to_addr = || {
@@ -346,7 +346,7 @@ impl ProxyScheme {
"socks5" => Self::socks5(to_addr()?)?, "socks5" => Self::socks5(to_addr()?)?,
#[cfg(feature = "socks")] #[cfg(feature = "socks")]
"socks5h" => Self::socks5h(to_addr()?)?, "socks5h" => Self::socks5h(to_addr()?)?,
_ => return Err(::error::unknown_proxy_scheme()) _ => return Err(crate::error::unknown_proxy_scheme())
}; };
if let Some(pwd) = url.password() { if let Some(pwd) = url.password() {
@@ -387,7 +387,7 @@ impl Intercept {
struct Custom { struct Custom {
// This auth only applies if the returned ProxyScheme doesn't have an auth... // This auth only applies if the returned ProxyScheme doesn't have an auth...
auth: Option<HeaderValue>, auth: Option<HeaderValue>,
func: Arc<dyn Fn(&Url) -> Option<::Result<ProxyScheme>> + Send + Sync + 'static>, func: Arc<dyn Fn(&Url) -> Option<crate::Result<ProxyScheme>> + Send + Sync + 'static>,
} }
impl Custom { impl Custom {

View File

@@ -1,6 +1,6 @@
use std::fmt; use std::fmt;
use header::{ use crate::header::{
HeaderMap, HeaderMap,
AUTHORIZATION, AUTHORIZATION,
COOKIE, COOKIE,
@@ -10,7 +10,7 @@ use header::{
}; };
use hyper::StatusCode; use hyper::StatusCode;
use Url; use crate::Url;
/// A type that controls the policy on how to handle the following of redirects. /// A type that controls the policy on how to handle the following of redirects.
/// ///

View File

@@ -5,10 +5,10 @@ use serde::Serialize;
use serde_json; use serde_json;
use serde_urlencoded; use serde_urlencoded;
use body::{self, Body}; use crate::body::{self, Body};
use header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE}; use crate::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE};
use http::HttpTryFrom; use http::HttpTryFrom;
use {async_impl, Client, Method, Url}; use crate::{async_impl, Client, Method, Url};
/// A request which can be executed with `Client::execute()`. /// A request which can be executed with `Client::execute()`.
pub struct Request { pub struct Request {
@@ -20,7 +20,7 @@ pub struct Request {
#[derive(Debug)] #[derive(Debug)]
pub struct RequestBuilder { pub struct RequestBuilder {
client: Client, client: Client,
request: ::Result<Request>, request: crate::Result<Request>,
} }
impl Request { impl Request {
@@ -102,7 +102,7 @@ impl Request {
} }
pub(crate) fn into_async(self) -> (async_impl::Request, Option<body::Sender>) { pub(crate) fn into_async(self) -> (async_impl::Request, Option<body::Sender>) {
use header::CONTENT_LENGTH; use crate::header::CONTENT_LENGTH;
let mut req_async = self.inner; let mut req_async = self.inner;
let body = self.body.and_then(|body| { let body = self.body.and_then(|body| {
@@ -118,7 +118,7 @@ impl Request {
} }
impl RequestBuilder { impl RequestBuilder {
pub(crate) fn new(client: Client, request: ::Result<Request>) -> RequestBuilder { pub(crate) fn new(client: Client, request: crate::Result<Request>) -> RequestBuilder {
RequestBuilder { RequestBuilder {
client, client,
request, request,
@@ -149,10 +149,10 @@ impl RequestBuilder {
Ok(key) => { Ok(key) => {
match <HeaderValue as HttpTryFrom<V>>::try_from(value) { match <HeaderValue as HttpTryFrom<V>>::try_from(value) {
Ok(value) => { req.headers_mut().append(key, value); } Ok(value) => { req.headers_mut().append(key, value); }
Err(e) => error = Some(::error::from(e.into())), Err(e) => error = Some(crate::error::from(e.into())),
} }
}, },
Err(e) => error = Some(::error::from(e.into())), Err(e) => error = Some(crate::error::from(e.into())),
}; };
} }
if let Some(err) = error { if let Some(err) = error {
@@ -186,7 +186,7 @@ impl RequestBuilder {
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
pub fn headers(mut self, headers: ::header::HeaderMap) -> RequestBuilder { pub fn headers(mut self, headers: crate::header::HeaderMap) -> RequestBuilder {
if let Ok(ref mut req) = self.request { if let Ok(ref mut req) = self.request {
async_impl::request::replace_headers(req.headers_mut(), headers); async_impl::request::replace_headers(req.headers_mut(), headers);
} }
@@ -239,7 +239,7 @@ impl RequestBuilder {
None => format!("{}:", username) None => format!("{}:", username)
}; };
let header_value = format!("Basic {}", encode(&auth)); let header_value = format!("Basic {}", encode(&auth));
self.header(::header::AUTHORIZATION, &*header_value) self.header(crate::header::AUTHORIZATION, &*header_value)
} }
/// Enable HTTP bearer authentication. /// Enable HTTP bearer authentication.
@@ -258,7 +258,7 @@ impl RequestBuilder {
T: fmt::Display, T: fmt::Display,
{ {
let header_value = format!("Bearer {}", token); let header_value = format!("Bearer {}", token);
self.header(::header::AUTHORIZATION, &*header_value) self.header(crate::header::AUTHORIZATION, &*header_value)
} }
/// Set the request body. /// Set the request body.
@@ -350,7 +350,7 @@ impl RequestBuilder {
let serializer = serde_urlencoded::Serializer::new(&mut pairs); let serializer = serde_urlencoded::Serializer::new(&mut pairs);
if let Err(err) = query.serialize(serializer) { if let Err(err) = query.serialize(serializer) {
error = Some(::error::from(err)); error = Some(crate::error::from(err));
} }
} }
if let Ok(ref mut req) = self.request { if let Ok(ref mut req) = self.request {
@@ -401,7 +401,7 @@ impl RequestBuilder {
); );
*req.body_mut() = Some(body.into()); *req.body_mut() = Some(body.into());
}, },
Err(err) => error = Some(::error::from(err)), Err(err) => error = Some(crate::error::from(err)),
} }
} }
if let Some(err) = error { if let Some(err) = error {
@@ -446,7 +446,7 @@ impl RequestBuilder {
); );
*req.body_mut() = Some(body.into()); *req.body_mut() = Some(body.into());
}, },
Err(err) => error = Some(::error::from(err)), Err(err) => error = Some(crate::error::from(err)),
} }
} }
if let Some(err) = error { if let Some(err) = error {
@@ -474,7 +474,7 @@ impl RequestBuilder {
/// ``` /// ```
/// ///
/// See [`multipart`](multipart/) for more examples. /// See [`multipart`](multipart/) for more examples.
pub fn multipart(self, mut multipart: ::multipart::Form) -> RequestBuilder { pub fn multipart(self, mut multipart: crate::multipart::Form) -> RequestBuilder {
let mut builder = self.header( let mut builder = self.header(
CONTENT_TYPE, CONTENT_TYPE,
format!( format!(
@@ -493,7 +493,7 @@ impl RequestBuilder {
/// Build a `Request`, which can be inspected, modified and executed with /// Build a `Request`, which can be inspected, modified and executed with
/// `Client::execute()`. /// `Client::execute()`.
pub fn build(self) -> ::Result<Request> { pub fn build(self) -> crate::Result<Request> {
self.request self.request
} }
@@ -503,7 +503,7 @@ impl RequestBuilder {
/// ///
/// This method fails if there was an error while sending request, /// This method fails if there was an error while sending request,
/// redirect loop was detected or redirect limit was exhausted. /// redirect loop was detected or redirect limit was exhausted.
pub fn send(self) -> ::Result<::Response> { pub fn send(self) -> crate::Result<crate::Response> {
self.client.execute(self.request?) self.client.execute(self.request?)
} }
@@ -579,8 +579,8 @@ fn fmt_request_fields<'a, 'b>(f: &'a mut fmt::DebugStruct<'a, 'b>, req: &Request
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use {body, Client, Method}; use crate::{body, Client, Method};
use header::{ACCEPT, HOST, HeaderMap, HeaderValue, CONTENT_TYPE}; use crate::header::{ACCEPT, HOST, HeaderMap, HeaderValue, CONTENT_TYPE};
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use serde::Serialize; use serde::Serialize;
use serde_json; use serde_json;

View File

@@ -8,10 +8,10 @@ use futures::{Async, Poll, Stream};
use http; use http;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use cookie; use crate::cookie;
use client::KeepCoreThreadAlive; use crate::client::KeepCoreThreadAlive;
use hyper::header::HeaderMap; use hyper::header::HeaderMap;
use {async_impl, StatusCode, Url, Version, wait}; use crate::{async_impl, StatusCode, Url, Version, wait};
/// A Response to a submitted `Request`. /// A Response to a submitted `Request`.
pub struct Response { pub struct Response {
@@ -201,11 +201,11 @@ impl Response {
/// details please see [`serde_json::from_reader`]. /// details please see [`serde_json::from_reader`].
/// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html /// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html
#[inline] #[inline]
pub fn json<T: DeserializeOwned>(&mut self) -> ::Result<T> { pub fn json<T: DeserializeOwned>(&mut self) -> crate::Result<T> {
wait::timeout(self.inner.json(), self.timeout).map_err(|e| { wait::timeout(self.inner.json(), self.timeout).map_err(|e| {
match e { match e {
wait::Waited::TimedOut => ::error::timedout(None), wait::Waited::TimedOut => crate::error::timedout(None),
wait::Waited::Executor(e) => ::error::from(e), wait::Waited::Executor(e) => crate::error::from(e),
wait::Waited::Inner(e) => e, wait::Waited::Inner(e) => e,
} }
}) })
@@ -232,7 +232,7 @@ impl Response {
/// ///
/// This consumes the body. Trying to read more, or use of `response.json()` /// This consumes the body. Trying to read more, or use of `response.json()`
/// will return empty values. /// will return empty values.
pub fn text(&mut self) -> ::Result<String> { pub fn text(&mut self) -> crate::Result<String> {
self.text_with_charset("utf-8") self.text_with_charset("utf-8")
} }
@@ -259,11 +259,11 @@ impl Response {
/// ///
/// This consumes the body. Trying to read more, or use of `response.json()` /// This consumes the body. Trying to read more, or use of `response.json()`
/// will return empty values. /// will return empty values.
pub fn text_with_charset(&mut self, default_encoding: &str) -> ::Result<String> { pub fn text_with_charset(&mut self, default_encoding: &str) -> crate::Result<String> {
wait::timeout(self.inner.text_with_charset(default_encoding), self.timeout).map_err(|e| { wait::timeout(self.inner.text_with_charset(default_encoding), self.timeout).map_err(|e| {
match e { match e {
wait::Waited::TimedOut => ::error::timedout(None), wait::Waited::TimedOut => crate::error::timedout(None),
wait::Waited::Executor(e) => ::error::from(e), wait::Waited::Executor(e) => crate::error::from(e),
wait::Waited::Inner(e) => e, wait::Waited::Inner(e) => e,
} }
}) })
@@ -290,10 +290,10 @@ impl Response {
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
pub fn copy_to<W: ?Sized>(&mut self, w: &mut W) -> ::Result<u64> pub fn copy_to<W: ?Sized>(&mut self, w: &mut W) -> crate::Result<u64>
where W: io::Write where W: io::Write
{ {
io::copy(self, w).map_err(::error::from) io::copy(self, w).map_err(crate::error::from)
} }
/// Turn a response into an error if the server returned an error. /// Turn a response into an error if the server returned an error.
@@ -313,7 +313,7 @@ impl Response {
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
#[inline] #[inline]
pub fn error_for_status(self) -> ::Result<Self> { pub fn error_for_status(self) -> crate::Result<Self> {
let Response { body, inner, timeout, _thread_handle } = self; let Response { body, inner, timeout, _thread_handle } = self;
inner.error_for_status().map(move |inner| { inner.error_for_status().map(move |inner| {
Response { Response {
@@ -342,7 +342,7 @@ impl Response {
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
#[inline] #[inline]
pub fn error_for_status_ref(&self) -> ::Result<&Self> { pub fn error_for_status_ref(&self) -> crate::Result<&Self> {
self.inner.error_for_status_ref().and_then(|_| Ok(self)) self.inner.error_for_status_ref().and_then(|_| Ok(self))
} }
} }
@@ -377,8 +377,8 @@ impl Stream for WaitBody {
Some(Ok(chunk)) => Ok(Async::Ready(Some(chunk))), Some(Ok(chunk)) => Ok(Async::Ready(Some(chunk))),
Some(Err(e)) => { Some(Err(e)) => {
let req_err = match e { let req_err = match e {
wait::Waited::TimedOut => ::error::timedout(None), wait::Waited::TimedOut => crate::error::timedout(None),
wait::Waited::Executor(e) => ::error::from(e), wait::Waited::Executor(e) => crate::error::from(e),
wait::Waited::Inner(e) => e, wait::Waited::Inner(e) => e,
}; };

View File

@@ -52,7 +52,7 @@ impl Certificate {
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
pub fn from_der(der: &[u8]) -> ::Result<Certificate> { pub fn from_der(der: &[u8]) -> crate::Result<Certificate> {
Ok(Certificate { Ok(Certificate {
#[cfg(feature = "default-tls")] #[cfg(feature = "default-tls")]
native: try_!(::native_tls::Certificate::from_der(der)), native: try_!(::native_tls::Certificate::from_der(der)),
@@ -78,7 +78,7 @@ impl Certificate {
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
pub fn from_pem(pem: &[u8]) -> ::Result<Certificate> { pub fn from_pem(pem: &[u8]) -> crate::Result<Certificate> {
Ok(Certificate { Ok(Certificate {
#[cfg(feature = "default-tls")] #[cfg(feature = "default-tls")]
native: try_!(::native_tls::Certificate::from_pem(pem)), native: try_!(::native_tls::Certificate::from_pem(pem)),
@@ -149,7 +149,7 @@ impl Identity {
/// # } /// # }
/// ``` /// ```
#[cfg(feature = "default-tls")] #[cfg(feature = "default-tls")]
pub fn from_pkcs12_der(der: &[u8], password: &str) -> ::Result<Identity> { pub fn from_pkcs12_der(der: &[u8], password: &str) -> crate::Result<Identity> {
Ok(Identity { Ok(Identity {
inner: ClientCert::Pkcs12( inner: ClientCert::Pkcs12(
try_!(::native_tls::Identity::from_pkcs12(der, password)) try_!(::native_tls::Identity::from_pkcs12(der, password))
@@ -218,7 +218,7 @@ impl Identity {
pub(crate) fn add_to_native_tls( pub(crate) fn add_to_native_tls(
self, self,
tls: &mut ::native_tls::TlsConnectorBuilder, tls: &mut ::native_tls::TlsConnectorBuilder,
) -> ::Result<()> { ) -> crate::Result<()> {
match self.inner { match self.inner {
ClientCert::Pkcs12(id) => { ClientCert::Pkcs12(id) => {
tls.identity(id); tls.identity(id);

View File

@@ -14,8 +14,8 @@ use std::time::Duration;
use futures::{Future, Stream}; use futures::{Future, Stream};
use tokio::runtime::current_thread::Runtime; use tokio::runtime::current_thread::Runtime;
use reqwest::async::Client; use reqwest::r#async::Client;
use reqwest::async::multipart::{Form, Part}; use reqwest::r#async::multipart::{Form, Part};
use bytes::Bytes; use bytes::Bytes;

View File

@@ -6,7 +6,7 @@ mod support;
#[test] #[test]
fn cookie_response_accessor() { fn cookie_response_accessor() {
let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt"); let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
let client = reqwest::async::Client::new(); let client = reqwest::r#async::Client::new();
let server = server! { let server = server! {
request: b"\ request: b"\
@@ -81,7 +81,7 @@ fn cookie_response_accessor() {
#[test] #[test]
fn cookie_store_simple() { fn cookie_store_simple() {
let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt"); let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
let client = reqwest::async::Client::builder().cookie_store(true).build().unwrap(); let client = reqwest::r#async::Client::builder().cookie_store(true).build().unwrap();
let server = server! { let server = server! {
request: b"\ request: b"\
@@ -125,7 +125,7 @@ fn cookie_store_simple() {
#[test] #[test]
fn cookie_store_overwrite_existing() { fn cookie_store_overwrite_existing() {
let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt"); let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
let client = reqwest::async::Client::builder().cookie_store(true).build().unwrap(); let client = reqwest::r#async::Client::builder().cookie_store(true).build().unwrap();
let server = server! { let server = server! {
request: b"\ request: b"\
@@ -189,7 +189,7 @@ fn cookie_store_overwrite_existing() {
#[test] #[test]
fn cookie_store_max_age() { fn cookie_store_max_age() {
let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt"); let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
let client = reqwest::async::Client::builder().cookie_store(true).build().unwrap(); let client = reqwest::r#async::Client::builder().cookie_store(true).build().unwrap();
let server = server! { let server = server! {
request: b"\ request: b"\
@@ -232,7 +232,7 @@ fn cookie_store_max_age() {
#[test] #[test]
fn cookie_store_expires() { fn cookie_store_expires() {
let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt"); let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
let client = reqwest::async::Client::builder().cookie_store(true).build().unwrap(); let client = reqwest::r#async::Client::builder().cookie_store(true).build().unwrap();
let server = server! { let server = server! {
request: b"\ request: b"\
@@ -275,7 +275,7 @@ fn cookie_store_expires() {
#[test] #[test]
fn cookie_store_path() { fn cookie_store_path() {
let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt"); let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
let client = reqwest::async::Client::builder().cookie_store(true).build().unwrap(); let client = reqwest::r#async::Client::builder().cookie_store(true).build().unwrap();
let server = server! { let server = server! {
request: b"\ request: b"\

View File

@@ -196,14 +196,14 @@ macro_rules! server {
$($f: $v,)+ $($f: $v,)+
}),* }),*
]; ];
::support::server::spawn(txns) crate::support::server::spawn(txns)
}) })
} }
#[macro_export] #[macro_export]
macro_rules! __internal__txn { macro_rules! __internal__txn {
($($field:ident: $val:expr,)+) => ( ($($field:ident: $val:expr,)+) => (
::support::server::Txn { crate::support::server::Txn {
$( $field: __internal__prop!($field: $val), )+ $( $field: __internal__prop!($field: $val), )+
.. Default::default() .. Default::default()
} }