feat(upgrade): Moved HTTP upgrades off Body to a new API (#2337)

Closes #2086

BREAKING CHANGE: The method `Body::on_upgrade()` is gone. It is
  essentially replaced with `hyper::upgrade::on(msg)`.
This commit is contained in:
Sean McArthur
2020-11-19 16:36:12 -08:00
committed by GitHub
parent 751c122589
commit 121c33132c
6 changed files with 62 additions and 27 deletions

View File

@@ -1790,9 +1790,7 @@ mod dispatch_impl {
let res = rt.block_on(future::join(res, rx).map(|r| r.0)).unwrap();
assert_eq!(res.status(), 101);
let upgraded = rt
.block_on(res.into_body().on_upgrade())
.expect("on_upgrade");
let upgraded = rt.block_on(hyper::upgrade::on(res)).expect("on_upgrade");
let parts = upgraded.downcast::<DebugStream>().unwrap();
assert_eq!(s(&parts.read_buf), "foobar=ready");

View File

@@ -1341,7 +1341,7 @@ async fn upgrades_new() {
let (upgrades_tx, upgrades_rx) = mpsc::channel();
let svc = service_fn(move |req: Request<Body>| {
let on_upgrade = req.into_body().on_upgrade();
let on_upgrade = hyper::upgrade::on(req);
let _ = upgrades_tx.send(on_upgrade);
future::ok::<_, hyper::Error>(
Response::builder()
@@ -1448,7 +1448,7 @@ async fn http_connect_new() {
let (upgrades_tx, upgrades_rx) = mpsc::channel();
let svc = service_fn(move |req: Request<Body>| {
let on_upgrade = req.into_body().on_upgrade();
let on_upgrade = hyper::upgrade::on(req);
let _ = upgrades_tx.send(on_upgrade);
future::ok::<_, hyper::Error>(
Response::builder()