Skip to content

Commit

Permalink
client bugfix: check the existing buffer before attempting to read fr…
Browse files Browse the repository at this point in the history
…om the network
  • Loading branch information
jbr committed Dec 19, 2023
1 parent ea52e21 commit f1dfc4e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,14 @@ impl Conn {
let mut len = buffer.len();
let mut search_start = 0;
let finder = Finder::new(b"\r\n\r\n");

if len > 0 {
if let Some(index) = finder.find(buffer) {
return Ok(index + 4);
}
search_start = len.saturating_sub(3);
}

loop {
buffer.expand();
let bytes = transport.read(&mut buffer[len..]).await?;
Expand Down

0 comments on commit f1dfc4e

Please sign in to comment.