-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set negative value to second argument of esp_http_client_open
method if request header has Transfer-Encoding: chunked
#310
Changes from 3 commits
a86d5f7
0da0e59
adeaca5
a7d084c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 as _) })?; | ||
esp!(unsafe { | ||
esp_http_client_open( | ||
self.raw_client, | ||
if self.is_chunked_streaming_request(headers) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the |
||
-1 | ||
} else { | ||
self.request_content_len as i32 | ||
}, | ||
) | ||
})?; | ||
|
||
self.state = State::Request; | ||
|
||
|
@@ -399,7 +408,7 @@ impl EspHttpConnection { | |
})?; | ||
esp!(unsafe { esp_http_client_set_redirection(self.raw_client) })?; | ||
esp!(unsafe { | ||
esp_http_client_open(self.raw_client, self.request_content_len as _) | ||
esp_http_client_open(self.raw_client, self.request_content_len as i32) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please just change the type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, change type to |
||
})?; | ||
|
||
self.headers.clear(); | ||
|
@@ -442,6 +451,18 @@ impl EspHttpConnection { | |
panic!("connection is not in response phase"); | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you don't need this method at all. This post says, that as long as you pass |
||
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 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you'll change
request_content_len
toi64
, as suggested below, just do hereunwrap_or(-1)