From 76a340574e2430631686f1fe53be42997791a942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 4 Jul 2020 19:38:37 +0200 Subject: [PATCH] aquatic_http: debug log StreamEnded, keep connection on parse error --- TODO.md | 1 - aquatic_http/src/lib/network/mod.rs | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 60f317a..5fdd68b 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,6 @@ * test tls * current serialized byte strings valid * scrape: does it work with multiple hashes? -* StreamEnded isn't really an error and should really only be debug-logged * non-compact peers for ipv6 generally: use ResponsePeerList enum * on ipv6, compact=1 should result in error response * on ipv4, compact=0 should result in error response diff --git a/aquatic_http/src/lib/network/mod.rs b/aquatic_http/src/lib/network/mod.rs index 74d4072..e531d70 100644 --- a/aquatic_http/src/lib/network/mod.rs +++ b/aquatic_http/src/lib/network/mod.rs @@ -240,13 +240,23 @@ pub fn handle_connection_read_event( break; }, - Err(err) => { - info!("error reading request: {:?}", err); + Err(RequestReadError::StreamEnded) => { + ::log::debug!("stream ended"); + + connections.remove(&poll_token); + + break + }, + Err(RequestReadError::Parse(err)) => { + ::log::info!("request httparse error: {}", err); + + break + }, + Err(RequestReadError::Io(err)) => { + ::log::info!("error reading request (io): {}", err); connections.remove(&poll_token); - // Stop reading data. Later events don't matter since - // connection was just removed. break; }, }