From 0da0e596f0c89cd3e6ccef6971daacf9604655b2 Mon Sep 17 00:00:00 2001 From: yoshiaki-yamada Date: Mon, 30 Oct 2023 17:40:47 +0900 Subject: [PATCH] Pass negative value if header has --- src/http/client.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/http/client.rs b/src/http/client.rs index db31609d4d8..e4c6b845e3a 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -248,7 +248,16 @@ impl EspHttpConnection { self.request_content_len = content_len.unwrap_or(0); - esp!(unsafe { esp_http_client_open(self.raw_client, self.request_content_len) })?; + esp!(unsafe { + esp_http_client_open( + self.raw_client, + if self.is_chunked_streaming_request(headers) { + -1 + } else { + self.request_content_len + }, + ) + })?; self.state = State::Request; @@ -442,6 +451,18 @@ impl EspHttpConnection { panic!("connection is not in response phase"); } } + + fn is_chunked_streaming_request(&self, headers: &[(&str, &str)]) -> bool { + for (name, value) in headers { + if name.eq_ignore_ascii_case("Transfer-Encoding") + && value.eq_ignore_ascii_case("chunked") + { + return true; + } + } + + false + } } impl Drop for EspHttpConnection {