From ce15f02053deac69482a59e3df34f166604f23a3 Mon Sep 17 00:00:00 2001 From: arloor Date: Thu, 5 Sep 2024 08:49:51 +0800 Subject: [PATCH] refactor: Improve readability and maintainability of auto_proxy_stream.rs --- .../src/local/net/tcp/auto_proxy_stream.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs b/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs index 67b9c52b62d5..c7454cee19dd 100644 --- a/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs +++ b/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs @@ -356,11 +356,12 @@ async fn wait_response(tls_stream: &mut tokio_rustls::client::TlsStream { + return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "unexpected EOF")); + } Ok(n) => { - if n != 0 { - // 将读取到的数据追加到动态缓冲区 - buffer.put(&buf[0..n]); - } + // 将读取到的数据追加到动态缓冲区 + buffer.put(&buf[0..n]); // 尝试解析累积的数据 let mut headers = [httparse::EMPTY_HEADER; 400];