From 3821ca106318b22e23f4088ddc33260f06c47352 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 8 Mar 2022 01:07:25 +0000 Subject: [PATCH] relax response parsing fixes #2103 --- actix-http/CHANGES.md | 4 ++++ actix-http/src/h1/decoder.rs | 5 ++++- awc/src/request.rs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 7be5dccff..ce3f14059 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,6 +1,10 @@ # Changes ## Unreleased - 2021-xx-xx +### Fixed +- Allow spaces between header name and colon when parsing responses. [#2684] + +[#2684]: https://github.com/actix/actix-web/issues/2684 ## 3.0.2 - 2022-03-05 diff --git a/actix-http/src/h1/decoder.rs b/actix-http/src/h1/decoder.rs index 17b9b695c..5a2477cba 100644 --- a/actix-http/src/h1/decoder.rs +++ b/actix-http/src/h1/decoder.rs @@ -295,8 +295,11 @@ impl MessageType for ResponseHead { let (len, ver, status, h_len) = { let mut parsed: [httparse::Header<'_>; MAX_HEADERS] = EMPTY_HEADER_ARRAY; + let mut config = httparse::ParserConfig::default(); + config.allow_spaces_after_header_name_in_responses(true); + let mut res = httparse::Response::new(&mut parsed); - match res.parse(src)? { + match config.parse_response(&mut res, src)? { httparse::Status::Complete(len) => { let version = if res.version.unwrap() == 1 { Version::HTTP_11 diff --git a/awc/src/request.rs b/awc/src/request.rs index 8bcf1ee01..102db3c16 100644 --- a/awc/src/request.rs +++ b/awc/src/request.rs @@ -505,7 +505,7 @@ impl fmt::Debug for ClientRequest { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!( f, - "\nClientRequest {:?} {}:{}", + "\nClientRequest {:?} {} {}", self.head.version, self.head.method, self.head.uri )?; writeln!(f, " headers:")?;