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