@@ -593,14 +593,16 @@ pub(crate) fn set_stream(resp: &mut Response, url: String, unit: Option<Unit>, s
|
||||
fn read_next_line<R: Read>(reader: &mut R) -> IoResult<String> {
|
||||
let mut buf = Vec::new();
|
||||
let mut prev_byte_was_cr = false;
|
||||
let mut one = [0_u8];
|
||||
|
||||
loop {
|
||||
let byte = reader.bytes().next();
|
||||
let amt = reader.read(&mut one[..])?;
|
||||
|
||||
let byte = match byte {
|
||||
Some(b) => b?,
|
||||
None => return Err(IoError::new(ErrorKind::ConnectionAborted, "Unexpected EOF")),
|
||||
};
|
||||
if amt == 0 {
|
||||
return Err(IoError::new(ErrorKind::ConnectionAborted, "Unexpected EOF"));
|
||||
}
|
||||
|
||||
let byte = one[0];
|
||||
|
||||
if byte == b'\n' && prev_byte_was_cr {
|
||||
buf.pop(); // removing the '\r'
|
||||
|
||||
Reference in New Issue
Block a user