Set chunked Transfer-Encoding when using send
Previously, using `.send()` on `Request` would require to set either the Transfer-Encoding or the Content-Length header. In an effort to provide better ergonomics for this library and to avoid making users fall in a not-so obvious pitfall, the library should build a valid Request without asking the user to mess around with the headers. This commit attempts to fix this issue: if the user use `.send()` to provide an unknown sized reader, the chunked Transfer-Encoding will be used. Of course, there are prior checks to ensure we do not override the user wish, like if the user already set a Content-Length or a Transfer-Encoding. This commit fix an edge case where the Content-Length would not be automatically set if the Transfer-Encoding is set but not chunked.
This commit is contained in:
@@ -66,7 +66,7 @@ impl SizedReader {
|
||||
impl Payload {
|
||||
pub fn into_read(self) -> SizedReader {
|
||||
match self {
|
||||
Payload::Empty => SizedReader::new(None, Box::new(empty())),
|
||||
Payload::Empty => SizedReader::new(Some(0), Box::new(empty())),
|
||||
Payload::Text(text, _charset) => {
|
||||
#[cfg(feature = "charset")]
|
||||
let bytes = {
|
||||
|
||||
Reference in New Issue
Block a user