port all optional features to 2018-edition
This commit is contained in:
committed by
Sean McArthur
parent
4773408ae4
commit
3ba4b6eadf
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user