diff options
author | Keuin <[email protected]> | 2023-09-04 02:27:12 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-09-04 02:30:17 +0800 |
commit | 863473cdcb29d9989c39b4ff96bd54e14b13c6b6 (patch) | |
tree | c649cb434f3d5d376a1c4abb6b76761f0c41b1f3 /src/client.rs | |
parent | 143014a91e695106d8383ed173c482b3b4519663 (diff) |
bugfix: last character of response message is truncatedv0.1.1
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/client.rs b/src/client.rs index 1e2edc4..3fcf78f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -57,14 +57,15 @@ pub async fn handle_client( } if b == b'\n' && prev_is_cr { if i < msg.len() { - i -= 2; // remove CRLF from reported message string + i -= 1; // remove CRLF from reported message string } break; } i += 1; prev_is_cr = b == b'\r'; } - let msg = match std::str::from_utf8(&msg[..i]) { + let msg = if i < msg.len() { &msg[..i] } else { &msg }; + let msg = match std::str::from_utf8(msg) { Ok(s) => s, Err(why) => { warn!( |