From 90d560c307c0324bec1bd7e6962087ffd4475786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Mon, 1 Nov 2021 09:40:28 +0100 Subject: [PATCH] http glommio: stop looping if peer closed connection --- aquatic_http/src/lib/network.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aquatic_http/src/lib/network.rs b/aquatic_http/src/lib/network.rs index e84065f..2fecd6a 100644 --- a/aquatic_http/src/lib/network.rs +++ b/aquatic_http/src/lib/network.rs @@ -244,6 +244,11 @@ impl Connection { ::log::debug!("read"); let bytes_read = self.stream.read(&mut buf).await?; + + if bytes_read == 0 { + return Err(anyhow::anyhow!("peer closed connection")); + } + let request_buffer_end = self.request_buffer_position + bytes_read; if request_buffer_end > self.request_buffer.len() {