From 3ba4b6eadffc5950fe92f59c910e50e254bfabc2 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Thu, 8 Aug 2019 18:47:12 +0100 Subject: [PATCH] port all optional features to 2018-edition --- src/async_impl/body.rs | 14 ++++++------ src/async_impl/client.rs | 20 ++++++++--------- src/async_impl/multipart.rs | 6 ++--- src/async_impl/request.rs | 10 ++++----- src/async_impl/response.rs | 2 +- src/client.rs | 2 +- src/connect.rs | 45 ++++++++++++++++++------------------- src/cookie.rs | 4 ++-- src/error.rs | 28 +++++++++++------------ src/into_url.rs | 2 +- src/multipart.rs | 8 +++---- src/proxy.rs | 8 +++---- src/redirect.rs | 6 ++--- src/request.rs | 10 ++++----- src/tls.rs | 24 ++++++++++---------- tests/async.rs | 4 ++-- tests/gzip.rs | 6 ++--- tests/multipart.rs | 2 +- tests/support/server.rs | 4 ++-- tests/timeouts.rs | 2 +- 20 files changed, 103 insertions(+), 104 deletions(-) diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index d6ed1fe..47e88bb 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -13,7 +13,7 @@ pub struct Body { enum Inner { Reusable(Bytes), Hyper { - body: ::hyper::Body, + body: hyper::Body, timeout: Option, } } @@ -27,7 +27,7 @@ impl Body { } #[inline] - pub(crate) fn response(body: ::hyper::Body, timeout: Option) -> Body { + pub(crate) fn response(body: hyper::Body, timeout: Option) -> Body { Body { inner: Inner::Hyper { body, @@ -37,7 +37,7 @@ impl Body { } #[inline] - pub(crate) fn wrap(body: ::hyper::Body) -> Body { + pub(crate) fn wrap(body: hyper::Body) -> Body { Body { inner: Inner::Hyper { body, @@ -59,7 +59,7 @@ impl Body { } #[inline] - pub(crate) fn into_hyper(self) -> (Option, ::hyper::Body) { + pub(crate) fn into_hyper(self) -> (Option, hyper::Body) { match self.inner { Inner::Reusable(chunk) => (Some(chunk.clone()), chunk.into()), Inner::Hyper { body, timeout } => { @@ -154,14 +154,14 @@ where /// A `Chunk` can be treated like `&[u8]`. #[derive(Default)] pub struct Chunk { - inner: ::hyper::Chunk, + inner: hyper::Chunk, } impl Chunk { #[inline] pub(crate) fn from_chunk(chunk: Bytes) -> Chunk { Chunk { - inner: ::hyper::Chunk::from(chunk) + inner: hyper::Chunk::from(chunk) } } } @@ -186,7 +186,7 @@ impl AsRef<[u8]> for Chunk { } } -impl ::std::ops::Deref for Chunk { +impl std::ops::Deref for Chunk { type Target = [u8]; #[inline] fn deref(&self) -> &Self::Target { diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 4011af7..1670824 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -109,7 +109,7 @@ impl ClientBuilder { #[cfg(feature = "tls")] certs_verification: true, connect_timeout: None, - max_idle_per_host: ::std::usize::MAX, + max_idle_per_host: std::usize::MAX, proxies: Vec::new(), redirect_policy: RedirectPolicy::default(), referer: true, @@ -160,9 +160,9 @@ impl ClientBuilder { }, #[cfg(feature = "rustls-tls")] TlsBackend::Rustls => { - use ::tls::NoVerifier; + use crate::tls::NoVerifier; - let mut tls = ::rustls::ClientConfig::new(); + let mut tls = rustls::ClientConfig::new(); if config.http2_only { tls.set_protocols(&["h2".into()]); } else { @@ -195,7 +195,7 @@ impl ClientBuilder { connector.set_timeout(config.connect_timeout); - let mut builder = ::hyper::Client::builder(); + let mut builder = hyper::Client::builder(); if config.http2_only { builder.http2_only(true); } @@ -441,7 +441,7 @@ impl ClientBuilder { } } -type HyperClient = ::hyper::Client; +type HyperClient = hyper::Client; impl Client { /// Constructs a new `Client`. @@ -590,13 +590,13 @@ impl Client { (Some(reusable), body) }, None => { - (None, ::hyper::Body::empty()) + (None, hyper::Body::empty()) } }; self.proxy_auth(&uri, &mut headers); - let mut req = ::hyper::Request::builder() + let mut req = hyper::Request::builder() .method(method.clone()) .uri(uri.clone()) .body(body) @@ -826,10 +826,10 @@ impl Future for PendingRequest { debug!("redirecting to {:?} '{}'", self.method, self.url); let uri = expect_uri(&self.url); let body = match self.body { - Some(Some(ref body)) => ::hyper::Body::from(body.clone()), - _ => ::hyper::Body::empty(), + Some(Some(ref body)) => hyper::Body::from(body.clone()), + _ => hyper::Body::empty(), }; - let mut req = ::hyper::Request::builder() + let mut req = hyper::Request::builder() .method(self.method.clone()) .uri(uri.clone()) .body(body) diff --git a/src/async_impl/multipart.rs b/src/async_impl/multipart.rs index ccb76c4..d222469 100644 --- a/src/async_impl/multipart.rs +++ b/src/async_impl/multipart.rs @@ -512,7 +512,7 @@ mod tests { // These prints are for debug purposes in case the test fails println!( "START REAL\n{}\nEND REAL", - ::std::str::from_utf8(&out).unwrap() + std::str::from_utf8(&out).unwrap() ); println!("START EXPECTED\n{}\nEND EXPECTED", expected); assert_eq!(::std::str::from_utf8(&out).unwrap(), expected); @@ -538,10 +538,10 @@ mod tests { // These prints are for debug purposes in case the test fails println!( "START REAL\n{}\nEND REAL", - ::std::str::from_utf8(&out).unwrap() + std::str::from_utf8(&out).unwrap() ); println!("START EXPECTED\n{}\nEND EXPECTED", expected); - assert_eq!(::std::str::from_utf8(&out).unwrap(), expected); + assert_eq!(std::str::from_utf8(&out).unwrap(), expected); } #[test] diff --git a/src/async_impl/request.rs b/src/async_impl/request.rs index b87e9f0..a8e3c7b 100644 --- a/src/async_impl/request.rs +++ b/src/async_impl/request.rs @@ -142,11 +142,11 @@ impl RequestBuilder { #[cfg(feature = "hyper-011")] pub fn header_011(self, header: H) -> RequestBuilder where - H: ::hyper_011::header::Header, + H: crate::hyper_011::header::Header, { - let mut headers = ::hyper_011::Headers::new(); + let mut headers = crate::hyper_011::Headers::new(); headers.set(header); - let map = ::header::HeaderMap::from(headers); + let map = crate::header::HeaderMap::from(headers); self.headers(map) } @@ -155,8 +155,8 @@ impl RequestBuilder { /// This method is provided to ease migration, and requires the `hyper-011` /// Cargo feature enabled on `reqwest`. #[cfg(feature = "hyper-011")] - pub fn headers_011(self, headers: ::hyper_011::Headers) -> RequestBuilder { - let map = ::header::HeaderMap::from(headers); + pub fn headers_011(self, headers: crate::hyper_011::Headers) -> RequestBuilder { + let map = crate::header::HeaderMap::from(headers); self.headers(map) } diff --git a/src/async_impl/response.rs b/src/async_impl/response.rs index 118f8a2..1634118 100644 --- a/src/async_impl/response.rs +++ b/src/async_impl/response.rs @@ -37,7 +37,7 @@ pub struct Response { } impl Response { - pub(super) fn new(res: ::hyper::Response<::hyper::Body>, url: Url, gzip: bool, timeout: Option) -> Response { + pub(super) fn new(res: hyper::Response<::hyper::Body>, url: Url, gzip: bool, timeout: Option) -> Response { let (parts, body) = res.into_parts(); let status = parts.status; let version = parts.version; diff --git a/src/client.rs b/src/client.rs index 9b6ea21..9a96296 100644 --- a/src/client.rs +++ b/src/client.rs @@ -603,7 +603,7 @@ impl ClientHandle { Ok(Async::Ready(())) } }); - ::tokio::spawn(task); + tokio::spawn(task); Ok(()) }); diff --git a/src/connect.rs b/src/connect.rs index 0b11ad9..9c7c37e 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -1,9 +1,8 @@ -use futures::{Future, try_ready}; +use futures::Future; use http::uri::Scheme; use hyper::client::connect::{Connect, Connected, Destination}; use tokio_io::{AsyncRead, AsyncWrite}; use tokio_timer::Timeout; -use log::{trace, debug}; #[cfg(feature = "default-tls")] use native_tls::{TlsConnector, TlsConnectorBuilder}; @@ -18,13 +17,13 @@ use std::net::IpAddr; use std::time::Duration; #[cfg(feature = "trust-dns")] -use dns::TrustDnsResolver; +use crate::dns::TrustDnsResolver; use crate::proxy::{Proxy, ProxyScheme}; #[cfg(feature = "trust-dns")] -type HttpConnector = ::hyper::client::HttpConnector; +type HttpConnector = hyper::client::HttpConnector; #[cfg(not(feature = "trust-dns"))] -type HttpConnector = ::hyper::client::HttpConnector; +type HttpConnector = hyper::client::HttpConnector; pub(crate) struct Connector { @@ -50,7 +49,7 @@ enum Inner { impl Connector { #[cfg(not(feature = "tls"))] - pub(crate) fn new(proxies: Arc>, local_addr: T, nodelay: bool) -> ::Result + pub(crate) fn new(proxies: Arc>, local_addr: T, nodelay: bool) -> crate::Result where T: Into> { @@ -93,7 +92,7 @@ impl Connector { tls: rustls::ClientConfig, proxies: Arc>, local_addr: T, - nodelay: bool) -> ::Result + nodelay: bool) -> crate::Result where T: Into>, { @@ -197,10 +196,10 @@ impl Connector { } #[cfg(feature = "trust-dns")] -fn http_connector() -> ::Result { +fn http_connector() -> crate::Result { TrustDnsResolver::new() .map(HttpConnector::new_with_resolver) - .map_err(::error::dns_system_conf) + .map_err(crate::error::dns_system_conf) } #[cfg(not(feature = "trust-dns"))] @@ -250,10 +249,10 @@ impl Connect for Connector { http.set_nodelay(nodelay || ($dst.scheme() == "https")); - let http = ::hyper_tls::HttpsConnector::from((http, tls.clone())); + let http = hyper_tls::HttpsConnector::from((http, tls.clone())); timeout!(http.connect($dst) .and_then(move |(io, connected)| { - if let ::hyper_tls::MaybeHttpsStream::Https(stream) = &io { + if let hyper_tls::MaybeHttpsStream::Https(stream) = &io { if !nodelay { stream.get_ref().get_ref().set_nodelay(false)?; } @@ -271,10 +270,10 @@ impl Connect for Connector { // https://www.openssl.org/docs/man1.1.1/man3/SSL_connect.html#NOTES http.set_nodelay(nodelay || ($dst.scheme() == "https")); - let http = ::hyper_rustls::HttpsConnector::from((http, tls.clone())); + let http = hyper_rustls::HttpsConnector::from((http, tls.clone())); timeout!(http.connect($dst) .and_then(move |(io, connected)| { - if let ::hyper_rustls::MaybeHttpsStream::Https(stream) = &io { + if let hyper_rustls::MaybeHttpsStream::Https(stream) = &io { if !nodelay { let (io, _) = stream.get_ref(); io.set_nodelay(false)?; @@ -290,7 +289,7 @@ impl Connect for Connector { for prox in self.proxies.iter() { if let Some(proxy_scheme) = prox.intercept(&dst) { - trace!("proxy({:?}) intercepts {:?}", proxy_scheme, dst); + log::trace!("proxy({:?}) intercepts {:?}", proxy_scheme, dst); let (puri, _auth) = match proxy_scheme { ProxyScheme::Http { uri, auth, .. } => (uri, auth), @@ -324,10 +323,10 @@ impl Connect for Connector { let port = dst.port().unwrap_or(443); let mut http = http.clone(); http.set_nodelay(nodelay); - let http = ::hyper_tls::HttpsConnector::from((http, tls.clone())); + let http = hyper_tls::HttpsConnector::from((http, tls.clone())); let tls = tls.clone(); return timeout!(http.connect(ndst).and_then(move |(conn, connected)| { - trace!("tunneling HTTPS over proxy"); + log::trace!("tunneling HTTPS over proxy"); tunnel(conn, host.clone(), port, auth) .and_then(move |tunneled| { tls.connect_async(&host, tunneled) @@ -346,10 +345,10 @@ impl Connect for Connector { let port = dst.port().unwrap_or(443); let mut http = http.clone(); http.set_nodelay(nodelay); - let http = ::hyper_rustls::HttpsConnector::from((http, tls_proxy.clone())); + let http = hyper_rustls::HttpsConnector::from((http, tls_proxy.clone())); let tls = tls.clone(); return timeout!(http.connect(ndst).and_then(move |(conn, connected)| { - trace!("tunneling HTTPS over proxy"); + log::trace!("tunneling HTTPS over proxy"); let maybe_dnsname = DNSNameRef::try_from_ascii_str(&host) .map(|dnsname| dnsname.to_owned()) .map_err(|_| io::Error::new(io::ErrorKind::Other, "Invalid DNS Name")); @@ -395,7 +394,7 @@ fn tunnel(conn: T, host: String, port: u16, auth: Option<::http::header::Head ", host, port).into_bytes(); if let Some(value) = auth { - debug!("tunnel to {}:{} using basic auth", host, port); + log::debug!("tunnel to {}:{} using basic auth", host, port); buf.extend_from_slice(b"Proxy-Authorization: "); buf.extend_from_slice(value.as_bytes()); buf.extend_from_slice(b"\r\n"); @@ -435,7 +434,7 @@ where fn poll(&mut self) -> Poll { loop { if let TunnelState::Writing = self.state { - let n = try_ready!(self.conn.as_mut().unwrap().write_buf(&mut self.buf)); + let n = futures::try_ready!(self.conn.as_mut().unwrap().write_buf(&mut self.buf)); if !self.buf.has_remaining_mut() { self.state = TunnelState::Reading; self.buf.get_mut().truncate(0); @@ -443,7 +442,7 @@ where return Err(tunnel_eof()); } } else { - let n = try_ready!(self.conn.as_mut().unwrap().read_buf(&mut self.buf.get_mut())); + let n = futures::try_ready!(self.conn.as_mut().unwrap().read_buf(&mut self.buf.get_mut())); let read = &self.buf.get_ref()[..]; if n == 0 { return Err(tunnel_eof()); @@ -497,7 +496,7 @@ mod native_tls_async { /// and both the server and the client are ready for receiving and sending /// data. Bytes read from a `TlsStream` are decrypted from `S` and bytes written /// to a `TlsStream` are encrypted when passing through to `S`. - #[derive(Debug)] + #[derive(log::debug)] pub struct TlsStream { inner: native_tls::TlsStream, } @@ -628,7 +627,7 @@ mod socks { use tokio::{net::TcpStream, reactor}; use super::{Connecting}; - use proxy::{ProxyScheme}; + use crate::proxy::{ProxyScheme}; pub(super) enum DnsResolve { Local, diff --git a/src/cookie.rs b/src/cookie.rs index e4b7faf..f3f1382 100644 --- a/src/cookie.rs +++ b/src/cookie.rs @@ -7,7 +7,7 @@ use std::fmt; use std::time::SystemTime; /// Convert a time::Tm time to SystemTime. -fn tm_to_systemtime(tm: ::time::Tm) -> SystemTime { +fn tm_to_systemtime(tm: time::Tm) -> SystemTime { let seconds = tm.to_timespec().sec; let duration = std::time::Duration::from_secs(seconds.abs() as u64); if seconds > 0 { @@ -129,7 +129,7 @@ pub(crate) fn extract_response_cookies<'a>( /// A persistent cookie store that provides session support. #[derive(Default)] -pub(crate) struct CookieStore(pub(crate) ::cookie_store::CookieStore); +pub(crate) struct CookieStore(pub(crate) cookie_store::CookieStore); impl<'a> fmt::Debug for CookieStore { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/error.rs b/src/error.rs index 0cb1ee4..8523f23 100644 --- a/src/error.rs +++ b/src/error.rs @@ -64,7 +64,7 @@ struct Inner { /// A `Result` alias where the `Err` case is `reqwest::Error`. -pub type Result = ::std::result::Result; +pub type Result = std::result::Result; impl Error { fn new(kind: Kind, url: Option) -> Error { @@ -416,21 +416,21 @@ pub(crate) enum Kind { impl From<::http::Error> for Kind { #[inline] - fn from(err: ::http::Error) -> Kind { + fn from(err: http::Error) -> Kind { Kind::Http(err) } } impl From<::hyper::Error> for Kind { #[inline] - fn from(err: ::hyper::Error) -> Kind { + fn from(err: hyper::Error) -> Kind { Kind::Hyper(err) } } impl From<::mime::FromStrError> for Kind { #[inline] - fn from(err: ::mime::FromStrError) -> Kind { + fn from(err: mime::FromStrError) -> Kind { Kind::Mime(err) } } @@ -444,35 +444,35 @@ impl From for Kind { impl From<::url::ParseError> for Kind { #[inline] - fn from(err: ::url::ParseError) -> Kind { + fn from(err: url::ParseError) -> Kind { Kind::Url(err) } } impl From<::serde_urlencoded::ser::Error> for Kind { #[inline] - fn from(err: ::serde_urlencoded::ser::Error) -> Kind { + fn from(err: serde_urlencoded::ser::Error) -> Kind { Kind::UrlEncoded(err) } } impl From<::serde_json::Error> for Kind { #[inline] - fn from(err: ::serde_json::Error) -> Kind { + fn from(err: serde_json::Error) -> Kind { Kind::Json(err) } } #[cfg(feature = "default-tls")] impl From<::native_tls::Error> for Kind { - fn from(err: ::native_tls::Error) -> Kind { + fn from(err: native_tls::Error) -> Kind { Kind::NativeTls(err) } } #[cfg(feature = "rustls-tls")] impl From<::rustls::TLSError> for Kind { - fn from(err: ::rustls::TLSError) -> Kind { + fn from(err: rustls::TLSError) -> Kind { Kind::Rustls(err) } } @@ -495,7 +495,7 @@ impl From for Kind { } impl From<::tokio::timer::Error> for Kind { - fn from(_err: ::tokio::timer::Error) -> Kind { + fn from(_err: tokio::timer::Error) -> Kind { Kind::Timer } } @@ -576,7 +576,7 @@ macro_rules! try_io { ($e:expr) => ( match $e { Ok(v) => v, - Err(ref err) if err.kind() == ::std::io::ErrorKind::WouldBlock => { + Err(ref err) if err.kind() == std::io::ErrorKind::WouldBlock => { return Ok(::futures::Async::NotReady); } Err(err) => { @@ -653,15 +653,15 @@ mod tests { } let root = Chain(None::); - let io = ::std::io::Error::new(::std::io::ErrorKind::Other, root); + let io = std::io::Error::new(::std::io::ErrorKind::Other, root); let err = Error::new(Kind::Io(io), None); assert!(err.cause().is_none()); assert_eq!(err.to_string(), "root"); - let root = ::std::io::Error::new(::std::io::ErrorKind::Other, Chain(None::)); + let root = std::io::Error::new(::std::io::ErrorKind::Other, Chain(None::)); let link = Chain(Some(root)); - let io = ::std::io::Error::new(::std::io::ErrorKind::Other, link); + let io = std::io::Error::new(::std::io::ErrorKind::Other, link); let err = Error::new(Kind::Io(io), None); assert!(err.cause().is_some()); assert_eq!(err.to_string(), "chain: root"); diff --git a/src/into_url.rs b/src/into_url.rs index db03fc9..1c66332 100644 --- a/src/into_url.rs +++ b/src/into_url.rs @@ -38,7 +38,7 @@ impl<'a> PolyfillTryInto for &'a String { } } -pub(crate) fn expect_uri(url: &Url) -> ::hyper::Uri { +pub(crate) fn expect_uri(url: &Url) -> hyper::Uri { url.as_str().parse().expect("a parsed Url should always be a valid Uri") } diff --git a/src/multipart.rs b/src/multipart.rs index 8bce09e..fe06264 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -95,7 +95,7 @@ impl Form { /// # Examples /// /// ```no_run - /// # fn run() -> ::std::io::Result<()> { + /// # fn run() -> std::io::Result<()> { /// let files = reqwest::multipart::Form::new() /// .file("key", "/path/to/file")?; /// # Ok(()) @@ -410,7 +410,7 @@ mod tests { // These prints are for debug purposes in case the test fails println!( "START REAL\n{}\nEND REAL", - ::std::str::from_utf8(&output).unwrap() + std::str::from_utf8(&output).unwrap() ); println!("START EXPECTED\n{}\nEND EXPECTED", expected); assert_eq!(::std::str::from_utf8(&output).unwrap(), expected); @@ -446,7 +446,7 @@ mod tests { // These prints are for debug purposes in case the test fails println!( "START REAL\n{}\nEND REAL", - ::std::str::from_utf8(&output).unwrap() + std::str::from_utf8(&output).unwrap() ); println!("START EXPECTED\n{}\nEND EXPECTED", expected); assert_eq!(::std::str::from_utf8(&output).unwrap(), expected); @@ -471,7 +471,7 @@ mod tests { // These prints are for debug purposes in case the test fails println!( "START REAL\n{}\nEND REAL", - ::std::str::from_utf8(&output).unwrap() + std::str::from_utf8(&output).unwrap() ); println!("START EXPECTED\n{}\nEND EXPECTED", expected); assert_eq!(::std::str::from_utf8(&output).unwrap(), expected); diff --git a/src/proxy.rs b/src/proxy.rs index b0c7291..6234341 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -52,7 +52,7 @@ pub struct Proxy { pub enum ProxyScheme { Http { auth: Option, - uri: ::hyper::Uri, + uri: hyper::Uri, }, #[cfg(feature = "socks")] Socks5 { @@ -279,7 +279,7 @@ impl ProxyScheme { /// /// Current SOCKS5 support is provided via blocking IO. #[cfg(feature = "socks")] - fn socks5(addr: SocketAddr) -> ::Result { + fn socks5(addr: SocketAddr) -> crate::Result { Ok(ProxyScheme::Socks5 { addr, auth: None, @@ -295,7 +295,7 @@ impl ProxyScheme { /// /// Current SOCKS5 support is provided via blocking IO. #[cfg(feature = "socks")] - fn socks5h(addr: SocketAddr) -> ::Result { + fn socks5h(addr: SocketAddr) -> crate::Result { Ok(ProxyScheme::Socks5 { addr, auth: None, @@ -337,7 +337,7 @@ impl ProxyScheme { let mut addr = try_!(host_and_port.to_socket_addrs()); addr .next() - .ok_or_else(::error::unknown_proxy_scheme) + .ok_or_else(crate::error::unknown_proxy_scheme) }; let mut scheme = match url.scheme() { diff --git a/src/redirect.rs b/src/redirect.rs index 88a8f66..600d7b1 100644 --- a/src/redirect.rs +++ b/src/redirect.rs @@ -261,12 +261,12 @@ and the compiler could not infer the lifetimes of those references. That means people would need to annotate the closure's argument types, which is garbase. pub trait Redirect { - fn redirect(&self, next: &Url, previous: &[Url]) -> ::Result; + fn redirect(&self, next: &Url, previous: &[Url]) -> Result; } impl Redirect for F -where F: Fn(&Url, &[Url]) -> ::Result { - fn redirect(&self, next: &Url, previous: &[Url]) -> ::Result { +where F: Fn(&Url, &[Url]) -> Result { + fn redirect(&self, next: &Url, previous: &[Url]) -> Result { self(next, previous) } } diff --git a/src/request.rs b/src/request.rs index 4886902..e3f5574 100644 --- a/src/request.rs +++ b/src/request.rs @@ -200,11 +200,11 @@ impl RequestBuilder { #[cfg(feature = "hyper-011")] pub fn header_011(self, header: H) -> RequestBuilder where - H: ::hyper_011::header::Header, + H: crate::hyper_011::header::Header, { - let mut headers = ::hyper_011::Headers::new(); + let mut headers = crate::hyper_011::Headers::new(); headers.set(header); - let map = ::header::HeaderMap::from(headers); + let map = crate::header::HeaderMap::from(headers); self.headers(map) } @@ -213,8 +213,8 @@ impl RequestBuilder { /// This method is provided to ease migration, and requires the `hyper-011` /// Cargo feature enabled on `reqwest`. #[cfg(feature = "hyper-011")] - pub fn headers_011(self, headers: ::hyper_011::Headers) -> RequestBuilder { - let map = ::header::HeaderMap::from(headers); + pub fn headers_011(self, headers: crate::hyper_011::Headers) -> RequestBuilder { + let map = crate::header::HeaderMap::from(headers); self.headers(map) } diff --git a/src/tls.rs b/src/tls.rs index 7a81ff5..8adb33a 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -8,7 +8,7 @@ use tokio_rustls::webpki::DNSNameRef; #[derive(Clone)] pub struct Certificate { #[cfg(feature = "default-tls")] - native: ::native_tls::Certificate, + native: native_tls::Certificate, #[cfg(feature = "rustls-tls")] original: Cert, } @@ -30,7 +30,7 @@ enum ClientCert { Pkcs12(::native_tls::Identity), #[cfg(feature = "rustls-tls")] Pem { - key: ::rustls::PrivateKey, + key: rustls::PrivateKey, certs: Vec<::rustls::Certificate>, } } @@ -90,7 +90,7 @@ impl Certificate { #[cfg(feature = "default-tls")] pub(crate) fn add_to_native_tls( self, - tls: &mut ::native_tls::TlsConnectorBuilder, + tls: &mut native_tls::TlsConnectorBuilder, ) { tls.add_root_certificate(self.native); } @@ -98,8 +98,8 @@ impl Certificate { #[cfg(feature = "rustls-tls")] pub(crate) fn add_to_rustls( self, - tls: &mut ::rustls::ClientConfig, - ) -> ::Result<()> { + tls: &mut rustls::ClientConfig, + ) -> crate::Result<()> { use std::io::Cursor; use rustls::internal::pemfile; @@ -177,7 +177,7 @@ impl Identity { /// # } /// ``` #[cfg(feature = "rustls-tls")] - pub fn from_pem(buf: &[u8]) -> ::Result { + pub fn from_pem(buf: &[u8]) -> crate::Result { use std::io::Cursor; use rustls::internal::pemfile; @@ -202,7 +202,7 @@ impl Identity { if let (Some(sk), false) = (sk.pop(), certs.is_empty()) { (sk, certs) } else { - return Err(::error::from(TLSError::General(String::from("private key or certificate not found")))); + return Err(crate::error::from(TLSError::General(String::from("private key or certificate not found")))); } }; @@ -217,7 +217,7 @@ impl Identity { #[cfg(feature = "default-tls")] pub(crate) fn add_to_native_tls( self, - tls: &mut ::native_tls::TlsConnectorBuilder, + tls: &mut native_tls::TlsConnectorBuilder, ) -> crate::Result<()> { match self.inner { ClientCert::Pkcs12(id) => { @@ -225,22 +225,22 @@ impl Identity { Ok(()) }, #[cfg(feature = "rustls-tls")] - ClientCert::Pem { .. } => Err(::error::from(::error::Kind::TlsIncompatible)) + ClientCert::Pem { .. } => Err(crate::error::from(crate::error::Kind::TlsIncompatible)) } } #[cfg(feature = "rustls-tls")] pub(crate) fn add_to_rustls( self, - tls: &mut ::rustls::ClientConfig, - ) -> ::Result<()> { + tls: &mut rustls::ClientConfig, + ) -> crate::Result<()> { match self.inner { ClientCert::Pem { key, certs } => { tls.set_single_client_cert(certs, key); Ok(()) }, #[cfg(feature = "default-tls")] - ClientCert::Pkcs12(..) => return Err(::error::from(::error::Kind::TlsIncompatible)) + ClientCert::Pkcs12(..) => Err(crate::error::from(crate::error::Kind::TlsIncompatible)) } } } diff --git a/tests/async.rs b/tests/async.rs index d9ddd80..f98996b 100644 --- a/tests/async.rs +++ b/tests/async.rs @@ -255,7 +255,7 @@ fn response_timeout() { fn gzip_case(response_size: usize, chunk_size: usize) { let content: String = (0..response_size).into_iter().map(|i| format!("test {}", i)).collect(); - let mut encoder = ::libflate::gzip::Encoder::new(Vec::new()).unwrap(); + let mut encoder = libflate::gzip::Encoder::new(Vec::new()).unwrap(); match encoder.write(content.as_bytes()) { Ok(n) => assert!(n > 0, "Failed to write to encoder."), _ => panic!("Failed to gzip encode string."), @@ -297,7 +297,7 @@ fn gzip_case(response_size: usize, chunk_size: usize) { body.concat2() }) .and_then(|buf| { - let body = ::std::str::from_utf8(&buf).unwrap(); + let body = std::str::from_utf8(&buf).unwrap(); assert_eq!(body, &content); diff --git a/tests/gzip.rs b/tests/gzip.rs index 9f634c5..4a373be 100644 --- a/tests/gzip.rs +++ b/tests/gzip.rs @@ -11,7 +11,7 @@ use std::io::{Read, Write}; fn test_gzip_response() { let content: String = (0..50).into_iter().map(|i| format!("test {}", i)).collect(); let chunk_size = content.len() / 3; - let mut encoder = ::libflate::gzip::Encoder::new(Vec::new()).unwrap(); + let mut encoder = libflate::gzip::Encoder::new(Vec::new()).unwrap(); match encoder.write(content.as_bytes()) { Ok(n) => assert!(n > 0, "Failed to write to encoder."), _ => panic!("Failed to gzip encode string."), @@ -74,7 +74,7 @@ fn test_gzip_empty_body() { .send() .unwrap(); - let mut body = ::std::string::String::new(); + let mut body = std::string::String::new(); res.read_to_string(&mut body).unwrap(); assert_eq!(body, ""); @@ -104,7 +104,7 @@ fn test_gzip_invalid_body() { // this tests that the request.send() didn't error, but that the error // is in reading the body - let mut body = ::std::string::String::new(); + let mut body = std::string::String::new(); res.read_to_string(&mut body).unwrap_err(); } diff --git a/tests/multipart.rs b/tests/multipart.rs index c415180..8e85d0d 100644 --- a/tests/multipart.rs +++ b/tests/multipart.rs @@ -57,7 +57,7 @@ fn file() { let form = reqwest::multipart::Form::new() .file("foo", "Cargo.lock").unwrap(); - let fcontents = ::std::fs::read_to_string("Cargo.lock").unwrap(); + let fcontents = std::fs::read_to_string("Cargo.lock").unwrap(); let expected_body = format!("\ --{0}\r\n\ diff --git a/tests/support/server.rs b/tests/support/server.rs index 0b39736..af8d345 100644 --- a/tests/support/server.rs +++ b/tests/support/server.rs @@ -97,9 +97,9 @@ pub fn spawn(txns: Vec) -> Server { } } - match (::std::str::from_utf8(&expected), ::std::str::from_utf8(&buf[..n])) { + match (::std::str::from_utf8(&expected), std::str::from_utf8(&buf[..n])) { (Ok(expected), Ok(received)) => { - if expected.len() > 300 && ::std::env::var("REQWEST_TEST_BODY_FULL").is_err() { + if expected.len() > 300 && std::env::var("REQWEST_TEST_BODY_FULL").is_err() { assert_eq!( expected.len(), received.len(), diff --git a/tests/timeouts.rs b/tests/timeouts.rs index ea80da4..0fd7f5f 100644 --- a/tests/timeouts.rs +++ b/tests/timeouts.rs @@ -81,7 +81,7 @@ fn write_timeout_large_body() { read_closes: true }; - let cursor = ::std::io::Cursor::new(body.into_bytes()); + let cursor = std::io::Cursor::new(body.into_bytes()); let url = format!("http://{}/write-timeout", server.addr()); let err = client .post(&url)