Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2307,17 +2307,19 @@ mod conn {
// Regression test for failure to fully close connections when using HTTP2 CONNECT
// We send 2 requests and then drop them. We should see the connection gracefully close.
use futures_util::future;
let (listener, addr) = setup_tk_test_server().await;
let (client_io, server_io) = tokio::io::duplex(1024);
let uri = http::Uri::builder()
.scheme("https")
.authority("hyper.rs")
.path_and_query("/")
.build()
.unwrap();
let (tx, rxx) = oneshot::channel::<()>();

tokio::task::spawn(async move {
use hyper::server::conn::http2;
use hyper::service::service_fn;

let res = listener.accept().await;
let (stream, _) = res.unwrap();
let stream = TokioIo::new(stream);

let service = service_fn(move |req: Request<hyper::body::Incoming>| {
tokio::task::spawn(async move {
let io = &mut TokioIo::new(hyper::upgrade::on(req).await.unwrap());
Expand All @@ -2328,15 +2330,15 @@ mod conn {
});

tokio::task::spawn(async move {
let conn = http2::Builder::new(TokioExecutor).serve_connection(stream, service);
let conn = http2::Builder::new(TokioExecutor)
.serve_connection(TokioIo::new(server_io), service);
let _ = conn.await;
tx.send(()).unwrap();
});
});

let io = tcp_connect(&addr).await.expect("tcp connect");
let (mut client, conn) = conn::http2::Builder::new(TokioExecutor)
.handshake(io)
.handshake(TokioIo::new(client_io))
.await
.expect("http handshake");

Expand All @@ -2358,7 +2360,7 @@ mod conn {
let rx = rxs.pop().unwrap();
let req = Request::builder()
.method(Method::CONNECT)
.uri(format!("{}", addr))
.uri(&uri)
.body(Empty::<Bytes>::new())
.expect("request builder");

Expand Down
Loading