Fix clippy warnings (#981)
* refactor: fix clippy warnings * refactor: fix redundant_closure * refactor: fix collapsible if * refactor: remove unnecessary_unwrap
This commit is contained in:
@@ -222,7 +222,7 @@ impl HttpBody for ImplStream {
|
|||||||
if bytes.is_empty() {
|
if bytes.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Ok(std::mem::replace(bytes, Bytes::new()).into()))
|
Some(Ok(std::mem::replace(bytes, Bytes::new())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1021,14 +1021,10 @@ impl Client {
|
|||||||
|
|
||||||
let accept_encoding = self.inner.accepts.as_str();
|
let accept_encoding = self.inner.accepts.as_str();
|
||||||
|
|
||||||
if accept_encoding.is_some()
|
if let Some(accept_encoding) = accept_encoding {
|
||||||
&& !headers.contains_key(ACCEPT_ENCODING)
|
if !headers.contains_key(ACCEPT_ENCODING) && !headers.contains_key(RANGE) {
|
||||||
&& !headers.contains_key(RANGE)
|
headers.insert(ACCEPT_ENCODING, HeaderValue::from_static(accept_encoding));
|
||||||
{
|
}
|
||||||
headers.insert(
|
|
||||||
ACCEPT_ENCODING,
|
|
||||||
HeaderValue::from_static(accept_encoding.unwrap()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let uri = expect_uri(&url);
|
let uri = expect_uri(&url);
|
||||||
@@ -1045,13 +1041,13 @@ impl Client {
|
|||||||
|
|
||||||
let mut req = hyper::Request::builder()
|
let mut req = hyper::Request::builder()
|
||||||
.method(method.clone())
|
.method(method.clone())
|
||||||
.uri(uri.clone())
|
.uri(uri)
|
||||||
.body(body.into_stream())
|
.body(body.into_stream())
|
||||||
.expect("valid request parts");
|
.expect("valid request parts");
|
||||||
|
|
||||||
let timeout = timeout
|
let timeout = timeout
|
||||||
.or(self.inner.request_timeout)
|
.or(self.inner.request_timeout)
|
||||||
.map(|dur| tokio::time::delay_for(dur));
|
.map(tokio::time::delay_for);
|
||||||
|
|
||||||
*req.headers_mut() = headers.clone();
|
*req.headers_mut() = headers.clone();
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ impl Stream for Decoder {
|
|||||||
}
|
}
|
||||||
Poll::Pending => return Poll::Pending,
|
Poll::Pending => return Poll::Pending,
|
||||||
},
|
},
|
||||||
Inner::PlainText(ref mut body) => return Pin::new(body).poll_next(cx),
|
Inner::PlainText(ref mut body) => Pin::new(body).poll_next(cx),
|
||||||
#[cfg(feature = "gzip")]
|
#[cfg(feature = "gzip")]
|
||||||
Inner::Gzip(ref mut decoder) => {
|
Inner::Gzip(ref mut decoder) => {
|
||||||
return match futures_core::ready!(Pin::new(decoder).poll_next(cx)) {
|
return match futures_core::ready!(Pin::new(decoder).poll_next(cx)) {
|
||||||
@@ -242,7 +242,7 @@ impl Stream for Decoder {
|
|||||||
None => Poll::Ready(None),
|
None => Poll::Ready(None),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ use std::future::Future;
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use base64;
|
|
||||||
use base64::write::EncoderWriter as Base64Encoder;
|
use base64::write::EncoderWriter as Base64Encoder;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
#[cfg(feature = "json")]
|
#[cfg(feature = "json")]
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use serde_urlencoded;
|
|
||||||
|
|
||||||
use super::body::Body;
|
use super::body::Body;
|
||||||
use super::client::{Client, Pending};
|
use super::client::{Client, Pending};
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use std::net::SocketAddr;
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use encoding_rs::{Encoding, UTF_8};
|
use encoding_rs::{Encoding, UTF_8};
|
||||||
use futures_util::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
use http;
|
|
||||||
use hyper::client::connect::HttpInfo;
|
use hyper::client::connect::HttpInfo;
|
||||||
use hyper::{HeaderMap, StatusCode, Version};
|
use hyper::{HeaderMap, StatusCode, Version};
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
|||||||
@@ -706,11 +706,9 @@ fn get_from_environment() -> SystemProxyMap {
|
|||||||
let mut proxies = HashMap::new();
|
let mut proxies = HashMap::new();
|
||||||
|
|
||||||
if is_cgi() {
|
if is_cgi() {
|
||||||
if log::log_enabled!(log::Level::Warn) {
|
if log::log_enabled!(log::Level::Warn) && env::var_os("HTTP_PROXY").is_some() {
|
||||||
if env::var_os("HTTP_PROXY").is_some() {
|
|
||||||
log::warn!("HTTP_PROXY environment variable ignored in CGI");
|
log::warn!("HTTP_PROXY environment variable ignored in CGI");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if !insert_from_env(&mut proxies, "http", "HTTP_PROXY") {
|
} else if !insert_from_env(&mut proxies, "http", "HTTP_PROXY") {
|
||||||
insert_from_env(&mut proxies, "http", "http_proxy");
|
insert_from_env(&mut proxies, "http", "http_proxy");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user