port all optional features to 2018-edition

This commit is contained in:
Daniel Eades
2019-08-08 18:47:12 +01:00
committed by Sean McArthur
parent 4773408ae4
commit 3ba4b6eadf
20 changed files with 103 additions and 104 deletions

View File

@@ -13,7 +13,7 @@ pub struct Body {
enum Inner {
Reusable(Bytes),
Hyper {
body: ::hyper::Body,
body: hyper::Body,
timeout: Option<Delay>,
}
}
@@ -27,7 +27,7 @@ impl Body {
}
#[inline]
pub(crate) fn response(body: ::hyper::Body, timeout: Option<Delay>) -> Body {
pub(crate) fn response(body: hyper::Body, timeout: Option<Delay>) -> 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<Bytes>, ::hyper::Body) {
pub(crate) fn into_hyper(self) -> (Option<Bytes>, 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 {

View File

@@ -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<Connector>;
type HyperClient = hyper::Client<Connector>;
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)

View File

@@ -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]

View File

@@ -142,11 +142,11 @@ impl RequestBuilder {
#[cfg(feature = "hyper-011")]
pub fn header_011<H>(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)
}

View File

@@ -37,7 +37,7 @@ pub struct Response {
}
impl Response {
pub(super) fn new(res: ::hyper::Response<::hyper::Body>, url: Url, gzip: bool, timeout: Option<Delay>) -> Response {
pub(super) fn new(res: hyper::Response<::hyper::Body>, url: Url, gzip: bool, timeout: Option<Delay>) -> Response {
let (parts, body) = res.into_parts();
let status = parts.status;
let version = parts.version;

View File

@@ -603,7 +603,7 @@ impl ClientHandle {
Ok(Async::Ready(()))
}
});
::tokio::spawn(task);
tokio::spawn(task);
Ok(())
});

View File

@@ -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<TrustDnsResolver>;
type HttpConnector = hyper::client::HttpConnector<TrustDnsResolver>;
#[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<T>(proxies: Arc<Vec<Proxy>>, local_addr: T, nodelay: bool) -> ::Result<Connector>
pub(crate) fn new<T>(proxies: Arc<Vec<Proxy>>, local_addr: T, nodelay: bool) -> crate::Result<Connector>
where
T: Into<Option<IpAddr>>
{
@@ -93,7 +92,7 @@ impl Connector {
tls: rustls::ClientConfig,
proxies: Arc<Vec<Proxy>>,
local_addr: T,
nodelay: bool) -> ::Result<Connector>
nodelay: bool) -> crate::Result<Connector>
where
T: Into<Option<IpAddr>>,
{
@@ -197,10 +196,10 @@ impl Connector {
}
#[cfg(feature = "trust-dns")]
fn http_connector() -> ::Result<HttpConnector> {
fn http_connector() -> crate::Result<HttpConnector> {
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<T>(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<Self::Item, Self::Error> {
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<S> {
inner: native_tls::TlsStream<S>,
}
@@ -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,

View File

@@ -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 {

View File

@@ -64,7 +64,7 @@ struct Inner {
/// A `Result` alias where the `Err` case is `reqwest::Error`.
pub type Result<T> = ::std::result::Result<T, Error>;
pub type Result<T> = std::result::Result<T, Error>;
impl Error {
fn new(kind: Kind, url: Option<Url>) -> 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<io::Error> 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<EnterError> 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::<Error>);
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::<Error>));
let root = std::io::Error::new(::std::io::ErrorKind::Other, Chain(None::<Error>));
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");

View File

@@ -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")
}

View File

@@ -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);

View File

@@ -52,7 +52,7 @@ pub struct Proxy {
pub enum ProxyScheme {
Http {
auth: Option<HeaderValue>,
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<Self> {
fn socks5(addr: SocketAddr) -> crate::Result<Self> {
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<Self> {
fn socks5h(addr: SocketAddr) -> crate::Result<Self> {
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() {

View File

@@ -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<bool>;
fn redirect(&self, next: &Url, previous: &[Url]) -> Result<bool>;
}
impl<F> Redirect for F
where F: Fn(&Url, &[Url]) -> ::Result<bool> {
fn redirect(&self, next: &Url, previous: &[Url]) -> ::Result<bool> {
where F: Fn(&Url, &[Url]) -> Result<bool> {
fn redirect(&self, next: &Url, previous: &[Url]) -> Result<bool> {
self(next, previous)
}
}

View File

@@ -200,11 +200,11 @@ impl RequestBuilder {
#[cfg(feature = "hyper-011")]
pub fn header_011<H>(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)
}

View File

@@ -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<Identity> {
pub fn from_pem(buf: &[u8]) -> crate::Result<Identity> {
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))
}
}
}

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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\

View File

@@ -97,9 +97,9 @@ pub fn spawn(txns: Vec<Txn>) -> 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(),

View File

@@ -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)