cargo fmt
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::stream::Stream;
|
||||
use std::io::{copy, empty, Cursor, Read, Write, Result as IoResult};
|
||||
use std::io::{copy, empty, Cursor, Read, Result as IoResult, Write};
|
||||
|
||||
#[cfg(feature = "charset")]
|
||||
use crate::response::DEFAULT_CHARACTER_SET;
|
||||
@@ -102,7 +102,6 @@ const CHUNK_HEADER_MAX_SIZE: usize = 6; // four hex digits plus "\r\n"
|
||||
const CHUNK_FOOTER_SIZE: usize = 2; // "\r\n"
|
||||
const CHUNK_MAX_PAYLOAD_SIZE: usize = CHUNK_MAX_SIZE - CHUNK_HEADER_MAX_SIZE - CHUNK_FOOTER_SIZE;
|
||||
|
||||
|
||||
// copy_chunks() improves over chunked_transfer's Encoder + io::copy with the
|
||||
// following performance optimizations:
|
||||
// 1) It avoid copying memory.
|
||||
@@ -117,7 +116,9 @@ fn copy_chunked<R: Read, W: Write>(reader: &mut R, writer: &mut W) -> IoResult<u
|
||||
loop {
|
||||
// We first read the payload
|
||||
chunk.resize(CHUNK_HEADER_MAX_SIZE, 0);
|
||||
let payload_size = reader.take(CHUNK_MAX_PAYLOAD_SIZE as u64).read_to_end(&mut chunk)?;
|
||||
let payload_size = reader
|
||||
.take(CHUNK_MAX_PAYLOAD_SIZE as u64)
|
||||
.read_to_end(&mut chunk)?;
|
||||
|
||||
// Then write the header
|
||||
let header_str = format!("{:x}\r\n", payload_size);
|
||||
|
||||
@@ -136,13 +136,15 @@ pub(crate) fn connect_http(unit: &Unit) -> Result<Stream, Error> {
|
||||
|
||||
#[cfg(all(feature = "tls", feature = "native-certs"))]
|
||||
fn configure_certs(config: &mut rustls::ClientConfig) {
|
||||
config.root_store = rustls_native_certs::load_native_certs()
|
||||
.expect("Could not load patform certs");
|
||||
config.root_store =
|
||||
rustls_native_certs::load_native_certs().expect("Could not load patform certs");
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "tls", not(feature = "native-certs")))]
|
||||
fn configure_certs(config: &mut rustls::ClientConfig) {
|
||||
config.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
config
|
||||
.root_store
|
||||
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
}
|
||||
|
||||
#[cfg(feature = "tls")]
|
||||
@@ -316,9 +318,9 @@ fn connect_socks5(
|
||||
// TODO: explore supporting timeouts upstream in Socks5Proxy.
|
||||
#[allow(clippy::mutex_atomic)]
|
||||
let stream = if timeout_connect > 0 {
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
use std::thread;
|
||||
use std::sync::mpsc::channel;
|
||||
let master_signal = Arc::new((Mutex::new(false), Condvar::new()));
|
||||
let slave_signal = master_signal.clone();
|
||||
let (tx, rx) = channel();
|
||||
|
||||
Reference in New Issue
Block a user