-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
differs/Legends
#5Labels
A-http1Area: HTTP/1 specific.Area: HTTP/1 specific.C-bugCategory: bug. Something is wrong. This is bad!Category: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.
Description
When sending a streaming request (using Body::channel) without content-length, the request terminates when dropping the Sender. But when a content-length is set, dropping the Sender before all bytes are sent will result in a request being stuck.
use hyper::{self, Body};
#[tokio::main]
async fn main() {
let (tx, body) = Body::channel();
let req = hyper::Request::builder()
.uri("http://httpbin.org/post")
.method(hyper::Method::POST)
.header("content-length", 1337)
.body(body)
.unwrap();
let client = hyper::Client::new();
std::mem::drop(tx);
println!("Sending request...");
let res = client.request(req).await.unwrap();
println!("Response: {:?}", res);
}The example above will terminate when the content-length header is removed, but like this it hangs until the server closes the connection.
On the other hand, when explicitly aborting the sender using tx.abort(), the request will terminate with an error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-http1Area: HTTP/1 specific.Area: HTTP/1 specific.C-bugCategory: bug. Something is wrong. This is bad!Category: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.