Fix more clippy warnings
This commit is contained in:
committed by
Sean McArthur
parent
4be5ec7ffd
commit
2881354c90
@@ -130,13 +130,13 @@ impl Request {
|
|||||||
/// `None` is returned if the request can not be cloned, i.e. if the body is a stream.
|
/// `None` is returned if the request can not be cloned, i.e. if the body is a stream.
|
||||||
pub fn try_clone(&self) -> Option<Request> {
|
pub fn try_clone(&self) -> Option<Request> {
|
||||||
let body = match self.body.as_ref() {
|
let body = match self.body.as_ref() {
|
||||||
Some(ref body) => Some(body.try_clone()?),
|
Some(body) => Some(body.try_clone()?),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
let mut req = Request::new(self.method().clone(), self.url().clone());
|
let mut req = Request::new(self.method().clone(), self.url().clone());
|
||||||
*req.timeout_mut() = self.timeout().cloned();
|
*req.timeout_mut() = self.timeout().cloned();
|
||||||
*req.headers_mut() = self.headers().clone();
|
*req.headers_mut() = self.headers().clone();
|
||||||
*req.version_mut() = self.version().clone();
|
*req.version_mut() = self.version();
|
||||||
req.body = body;
|
req.body = body;
|
||||||
Some(req)
|
Some(req)
|
||||||
}
|
}
|
||||||
@@ -565,7 +565,7 @@ where
|
|||||||
headers,
|
headers,
|
||||||
body: Some(body.into()),
|
body: Some(body.into()),
|
||||||
timeout: None,
|
timeout: None,
|
||||||
version: version,
|
version,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ impl Connector {
|
|||||||
.await?;
|
.await?;
|
||||||
let tls_connector = tokio_native_tls::TlsConnector::from(tls.clone());
|
let tls_connector = tokio_native_tls::TlsConnector::from(tls.clone());
|
||||||
let io = tls_connector
|
let io = tls_connector
|
||||||
.connect(&host.ok_or("no host in url")?, tunneled)
|
.connect(host.ok_or("no host in url")?, tunneled)
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(Conn {
|
return Ok(Conn {
|
||||||
inner: self.verbose.wrap(NativeTlsConn { inner: io }),
|
inner: self.verbose.wrap(NativeTlsConn { inner: io }),
|
||||||
@@ -1198,7 +1198,7 @@ mod tests {
|
|||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
use tokio::runtime;
|
use tokio::runtime;
|
||||||
|
|
||||||
static TUNNEL_UA: &'static str = "tunnel-test/x.y";
|
static TUNNEL_UA: &str = "tunnel-test/x.y";
|
||||||
static TUNNEL_OK: &[u8] = b"\
|
static TUNNEL_OK: &[u8] = b"\
|
||||||
HTTP/1.1 200 OK\r\n\
|
HTTP/1.1 200 OK\r\n\
|
||||||
\r\n\
|
\r\n\
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ fn js_fetch(req: &web_sys::Request) -> Promise {
|
|||||||
use wasm_bindgen::{JsCast, JsValue};
|
use wasm_bindgen::{JsCast, JsValue};
|
||||||
let global = js_sys::global();
|
let global = js_sys::global();
|
||||||
|
|
||||||
if let Some(true) =
|
if let Ok(true) = js_sys::Reflect::has(&global, &JsValue::from_str("ServiceWorkerGlobalScope"))
|
||||||
js_sys::Reflect::has(&global, &JsValue::from_str("ServiceWorkerGlobalScope")).ok()
|
|
||||||
{
|
{
|
||||||
global
|
global
|
||||||
.unchecked_into::<web_sys::ServiceWorkerGlobalScope>()
|
.unchecked_into::<web_sys::ServiceWorkerGlobalScope>()
|
||||||
@@ -213,7 +212,7 @@ async fn fetch(req: Request) -> crate::Result<Response> {
|
|||||||
|
|
||||||
if let Some(body) = req.body() {
|
if let Some(body) = req.body() {
|
||||||
if !body.is_empty() {
|
if !body.is_empty() {
|
||||||
init.body(Some(&body.to_js_value()?.as_ref().as_ref()));
|
init.body(Some(body.to_js_value()?.as_ref()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use http::{request::Parts, Method, Request as HttpRequest};
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
#[cfg(feature = "json")]
|
#[cfg(feature = "json")]
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use serde_urlencoded;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use web_sys::RequestCredentials;
|
use web_sys::RequestCredentials;
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ impl Request {
|
|||||||
/// None is returned if a body is which can not be cloned.
|
/// None is returned if a body is which can not be cloned.
|
||||||
pub fn try_clone(&self) -> Option<Request> {
|
pub fn try_clone(&self) -> Option<Request> {
|
||||||
let body = match self.body.as_ref() {
|
let body = match self.body.as_ref() {
|
||||||
Some(ref body) => Some(body.try_clone()?),
|
Some(body) => Some(body.try_clone()?),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,7 +105,7 @@ impl Request {
|
|||||||
headers: self.headers.clone(),
|
headers: self.headers.clone(),
|
||||||
body,
|
body,
|
||||||
cors: self.cors,
|
cors: self.cors,
|
||||||
credentials: self.credentials.clone(),
|
credentials: self.credentials,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ pub mod server;
|
|||||||
|
|
||||||
// TODO: remove once done converting to new support server?
|
// TODO: remove once done converting to new support server?
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub static DEFAULT_USER_AGENT: &'static str =
|
pub static DEFAULT_USER_AGENT: &str =
|
||||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
|
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ async fn connect_timeout() {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let url = format!("http://10.255.255.1:81/slow");
|
let url = "http://10.255.255.1:81/slow";
|
||||||
|
|
||||||
let res = client
|
let res = client
|
||||||
.get(&url)
|
.get(url)
|
||||||
.timeout(Duration::from_millis(1000))
|
.timeout(Duration::from_millis(1000))
|
||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
Reference in New Issue
Block a user