Skip to content

Commit

Permalink
Pass negative value if header has
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshiaki-yamada committed Oct 30, 2023
1 parent a86d5f7 commit 0da0e59
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0da0e59

Please sign in to comment.