Fix findings from cargo clippy.

This commit is contained in:
Jacob Hoffman-Andrews
2020-06-12 21:17:58 -07:00
committed by Martin Algesten
parent b4c15eef2c
commit 378ef57636
4 changed files with 10 additions and 15 deletions

View File

@@ -125,7 +125,7 @@ fn copy_chunked<R: Read, W: Write>(reader: &mut R, writer: &mut W) -> IoResult<u
let header = header_str.as_bytes(); let header = header_str.as_bytes();
assert!(header.len() <= CHUNK_HEADER_MAX_SIZE); assert!(header.len() <= CHUNK_HEADER_MAX_SIZE);
let start_index = CHUNK_HEADER_MAX_SIZE - header.len(); let start_index = CHUNK_HEADER_MAX_SIZE - header.len();
(&mut chunk[start_index..]).write(&header).unwrap(); (&mut chunk[start_index..]).write_all(&header).unwrap();
// And add the footer // And add the footer
chunk.extend_from_slice(b"\r\n"); chunk.extend_from_slice(b"\r\n");

View File

@@ -252,13 +252,11 @@ pub(crate) fn connect_host(unit: &Unit, hostname: &str, port: u16) -> Result<Tcp
hostname, hostname,
port, port,
) )
} else { } else if has_timeout {
if has_timeout {
let timeout = Duration::from_millis(timeout_connect); let timeout = Duration::from_millis(timeout_connect);
TcpStream::connect_timeout(&sock_addr, timeout) TcpStream::connect_timeout(&sock_addr, timeout)
} else { } else {
TcpStream::connect(&sock_addr) TcpStream::connect(&sock_addr)
}
}; };
if let Ok(stream) = stream { if let Ok(stream) = stream {

View File

@@ -1,7 +1,6 @@
use std::io::{Result as IoResult, Write}; use std::io::{Result as IoResult, Write};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use base64;
use qstring::QString; use qstring::QString;
use url::Url; use url::Url;

View File

@@ -47,7 +47,7 @@ fn agent_set_cookie() {
} }
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
const BADSSL_CLIENT_CERT_PEM: &'static str = r#"Bag Attributes const BADSSL_CLIENT_CERT_PEM: &str = r#"Bag Attributes
localKeyID: 41 C3 6C 33 C7 E3 36 DD EA 4A 1F C0 B7 23 B8 E6 9C DC D8 0F localKeyID: 41 C3 6C 33 C7 E3 36 DD EA 4A 1F C0 B7 23 B8 E6 9C DC D8 0F
subject=C = US, ST = California, L = San Francisco, O = BadSSL, CN = BadSSL Client Certificate subject=C = US, ST = California, L = San Francisco, O = BadSSL, CN = BadSSL Client Certificate
@@ -119,10 +119,8 @@ fn tls_client_certificate() {
let mut tls_config = rustls::ClientConfig::new(); let mut tls_config = rustls::ClientConfig::new();
let certs = let certs = rustls::internal::pemfile::certs(&mut BADSSL_CLIENT_CERT_PEM.as_bytes()).unwrap();
rustls::internal::pemfile::certs(&mut BADSSL_CLIENT_CERT_PEM.clone().as_bytes()).unwrap(); let key = rustls::internal::pemfile::rsa_private_keys(&mut BADSSL_CLIENT_CERT_PEM.as_bytes())
let key =
rustls::internal::pemfile::rsa_private_keys(&mut BADSSL_CLIENT_CERT_PEM.clone().as_bytes())
.unwrap()[0] .unwrap()[0]
.clone(); .clone();