Skip to content

Commit 49d4d85

Browse files
cleans protocol specfici test routing
This seems like the cleanes we can do without introducing a new trait or util.
1 parent 0d08bc7 commit 49d4d85

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

tests/server.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -3145,21 +3145,15 @@ impl TestClient {
31453145
.await
31463146
.unwrap();
31473147

3148-
// TODO(mike): cleaner
31493148
if self.http2_only {
3150-
let builder = hyper::client::conn::http2::Builder::new();
3151-
3152-
let (mut sender, conn) = builder.handshake(stream).await.unwrap();
3153-
3149+
let (mut sender, conn) = hyper::client::conn::http2::handshake(stream).await.unwrap();
31543150
tokio::task::spawn(async move {
31553151
conn.await.unwrap();
31563152
});
31573153

31583154
sender.send_request(req).await
31593155
} else {
3160-
let builder = hyper::client::conn::http1::Builder::new();
3161-
let (mut sender, conn) = builder.handshake(stream).await.unwrap();
3162-
3156+
let (mut sender, conn) = hyper::client::conn::http1::handshake(stream).await.unwrap();
31633157
tokio::task::spawn(async move {
31643158
conn.await.unwrap();
31653159
});

tests/support/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,8 @@ async fn async_test(cfg: __TestConfig) {
414414
async move {
415415
let stream = TcpStream::connect(addr).await.unwrap();
416416

417-
// TODO: cleaner way?
418417
let res = if http2_only {
419-
let (mut sender, conn) = hyper::client::conn::http2::Builder::new()
420-
.handshake::<TcpStream, Body>(stream)
418+
let (mut sender, conn) = hyper::client::conn::http2::handshake::<TcpStream>(stream)
421419
.await
422420
.unwrap();
423421

@@ -428,8 +426,7 @@ async fn async_test(cfg: __TestConfig) {
428426
});
429427
sender.send_request(req).await.unwrap()
430428
} else {
431-
let (mut sender, conn) = hyper::client::conn::http1::Builder::new()
432-
.handshake::<TcpStream, Body>(stream)
429+
let (mut sender, conn) = hyper::client::conn::http1::handshake::<TcpStream>(stream)
433430
.await
434431
.unwrap();
435432

@@ -516,28 +513,27 @@ async fn naive_proxy(cfg: ProxyConfig) -> (SocketAddr, impl Future<Output = ()>)
516513
let resp = if http2_only {
517514
let builder = hyper::client::conn::http2::Builder::new();
518515
let (mut sender, conn) = builder.handshake(stream).await.unwrap();
519-
516+
520517
tokio::task::spawn(async move {
521518
if let Err(err) = conn.await {
522519
panic!("{:?}", err);
523520
}
524521
});
525-
522+
526523
sender.send_request(req).await?
527524
} else {
528525
let builder = hyper::client::conn::http1::Builder::new();
529526
let (mut sender, conn) = builder.handshake(stream).await.unwrap();
530-
527+
531528
tokio::task::spawn(async move {
532529
if let Err(err) = conn.await {
533530
panic!("{:?}", err);
534531
}
535532
});
536-
533+
537534
sender.send_request(req).await?
538535
};
539536

540-
541537
let (mut parts, body) = resp.into_parts();
542538

543539
// Remove the Connection header for HTTP/1.1 proxy connections.

0 commit comments

Comments
 (0)