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:
@@ -47,7 +47,7 @@
|
||||
//! which follows a build pattern. The builders are finished using:
|
||||
//!
|
||||
//! * [`.call()`](struct.Request.html#method.call) without a request body.
|
||||
//! * [`.send()`](struct.Request.html#method.send) with a request body as `Read` (chunked encoding).
|
||||
//! * [`.send()`](struct.Request.html#method.send) with a request body as `Read` (chunked encoding support for non-known sized readers).
|
||||
//! * [`.send_string()`](struct.Request.html#method.send_string) body as string.
|
||||
//! * [`.send_bytes()`](struct.Request.html#method.send_bytes) body as bytes.
|
||||
//! * [`.send_form()`](struct.Request.html#method.send_form) key-value pairs as application/x-www-form-urlencoded.
|
||||
|
||||
Reference in New Issue
Block a user