mirror of https://github.com/fafhrd91/actix-net
Update lines.rs
This commit is contained in:
parent
d2e1cc38ad
commit
2ff8b2a706
|
@ -67,11 +67,9 @@ impl Decoder for LinesCodec {
|
||||||
Some(frame) => Ok(Some(frame)),
|
Some(frame) => Ok(Some(frame)),
|
||||||
None if src.is_empty() => Ok(None),
|
None if src.is_empty() => Ok(None),
|
||||||
None => {
|
None => {
|
||||||
let len = src.len();
|
|
||||||
|
|
||||||
let buf = match src.last() {
|
let buf = match src.last() {
|
||||||
// if last line ends in a CR then take everything up to it
|
// if last line ends in a CR then take everything up to it
|
||||||
Some(b'\r') => src.split_to(len - 1),
|
Some(b'\r') => src.split_to(src.len() - 1),
|
||||||
|
|
||||||
// take all bytes from source
|
// take all bytes from source
|
||||||
_ => src.split(),
|
_ => src.split(),
|
||||||
|
@ -81,7 +79,7 @@ impl Decoder for LinesCodec {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return try_into_utf8(buf.freeze());
|
try_into_utf8(buf.freeze())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue