tidy up
This commit is contained in:
@@ -19,7 +19,7 @@ pub enum Payload {
|
||||
Text(String, String),
|
||||
#[cfg(feature = "json")]
|
||||
JSON(SerdeValue),
|
||||
Reader(Box<Read + 'static>),
|
||||
Reader(Box<dyn Read + 'static>),
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for Payload {
|
||||
@@ -42,11 +42,11 @@ impl Default for Payload {
|
||||
|
||||
pub struct SizedReader {
|
||||
pub size: Option<usize>,
|
||||
pub reader: Box<Read + 'static>,
|
||||
pub reader: Box<dyn Read + 'static>,
|
||||
}
|
||||
|
||||
impl SizedReader {
|
||||
fn new(size: Option<usize>, reader: Box<Read + 'static>) -> Self {
|
||||
fn new(size: Option<usize>, reader: Box<dyn Read + 'static>) -> Self {
|
||||
SizedReader { size, reader }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ impl Response {
|
||||
|
||||
let use_chunked = !is_http10 && !is_head && is_chunked;
|
||||
|
||||
let expected_bytes = if is_http10 || is_close {
|
||||
let limit_bytes = if is_http10 || is_close {
|
||||
None
|
||||
} else if is_head {
|
||||
// head requests never have a body
|
||||
@@ -279,12 +279,12 @@ impl Response {
|
||||
let yolo = YoloRead { stream: stream_ptr };
|
||||
let unit = self.unit;
|
||||
|
||||
match (use_chunked, expected_bytes) {
|
||||
match (use_chunked, limit_bytes) {
|
||||
(true, _) => Box::new(PoolReturnRead::new(
|
||||
unit,
|
||||
stream_ptr,
|
||||
ChunkDecoder::new(yolo),
|
||||
)) as Box<Read>,
|
||||
)) as Box<dyn Read>,
|
||||
(false, Some(len)) => Box::new(PoolReturnRead::new(
|
||||
unit,
|
||||
stream_ptr,
|
||||
@@ -499,6 +499,7 @@ fn read_next_line<R: Read>(reader: &mut R) -> IoResult<AsciiString> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Read Wrapper around an (unsafe) pointer to a Stream.
|
||||
struct YoloRead {
|
||||
stream: *mut Stream,
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ pub enum Stream {
|
||||
Https(TlsStream<TcpStream>),
|
||||
Cursor(Cursor<Vec<u8>>),
|
||||
#[cfg(test)]
|
||||
Test(Box<Read + Send>, Vec<u8>),
|
||||
Test(Box<dyn Read + Send>, Vec<u8>),
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for Stream {
|
||||
|
||||
Reference in New Issue
Block a user