cargo fmt

This commit is contained in:
Martin Algesten
2020-05-06 13:48:52 +02:00
parent 4e744f87c1
commit 49b6072921
2 changed files with 12 additions and 9 deletions

View File

@@ -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;
@@ -97,12 +97,11 @@ impl Payload {
}
}
const CHUNK_MAX_SIZE: usize = 0x4000; // Maximum size of a TLS fragment
const CHUNK_MAX_SIZE: usize = 0x4000; // Maximum size of a TLS fragment
const CHUNK_HEADER_MAX_SIZE: usize = 6; // four hex digits plus "\r\n"
const CHUNK_FOOTER_SIZE: usize = 2; // "\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);