diff --git a/Cargo.lock b/Cargo.lock index 42e21306f1..8c0383fb0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5987,7 +5987,9 @@ dependencies = [ "futures", "glob", "h2 0.3.22", + "h2 0.4.0", "hyper 0.14.27", + "hyper 1.1.0", "lazy-regex", "libc", "lsp-types", diff --git a/Cargo.toml b/Cargo.toml index 80a7e9571c..b58977b787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,7 +106,9 @@ hex = "0.4" http = "0.2.9" h2 = { version = "0.3.17", features = ["unstable"] } httparse = "1.8.0" +hyper-util = { version = "=0.1.2", features = ["tokio", "server", "server-auto"] } hyper = { version = "0.14.26", features = ["runtime", "http1"] } +hyper1 = { package = "hyper", version = "=1.1.0", features = ["full"] } indexmap = { version = "2", features = ["serde"] } libc = "0.2.126" libz-sys = { version = "1.1", default-features = false } diff --git a/ext/http/Cargo.toml b/ext/http/Cargo.toml index 9aa583f698..2672516063 100644 --- a/ext/http/Cargo.toml +++ b/ext/http/Cargo.toml @@ -35,8 +35,8 @@ http.workspace = true http_1 = { package = "http", version = "=1.0.0" } httparse.workspace = true hyper = { workspace = true, features = ["server", "stream", "http1", "http2", "runtime"] } -hyper-util = { version = "=0.1.2", features = ["tokio"] } -hyper1 = { package = "hyper", features = ["full"], version = "=1.1.0" } +hyper-util.workspace = true +hyper1.workspace = true itertools = "0.10" memmem.workspace = true mime = "0.3.16" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index a00a4f6694..e7704dc9e6 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -105,8 +105,8 @@ http.workspace = true http-body-util = "0.1" http_1 = { package = "http", version = "1.0" } hyper = { workspace = true, features = ["server", "stream", "http1", "http2", "runtime"] } -hyper-util = { version = "0.1", features = ["server", "server-auto"] } -hyper1 = { package = "hyper", version = "1.0.1", features = ["server"] } +hyper-util.workspace = true +hyper1.workspace = true libc.workspace = true log.workspace = true netif = "0.1.6" diff --git a/test_util/Cargo.toml b/test_util/Cargo.toml index ac05af77ad..8e0e4d097b 100644 --- a/test_util/Cargo.toml +++ b/test_util/Cargo.toml @@ -25,7 +25,9 @@ flate2 = { workspace = true, features = ["default"] } futures.workspace = true glob.workspace = true h2.workspace = true +h2_04 = { package = "h2", version = "0.4" } hyper = { workspace = true, features = ["server", "http1", "http2", "runtime"] } +hyper1.workspace = true lazy-regex.workspace = true libc.workspace = true lsp-types.workspace = true diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index c4789621fb..555ba52711 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -11,10 +11,8 @@ use regex::Regex; use serde::Serialize; use std::collections::HashMap; use std::env; -use std::io; use std::io::Write; use std::path::PathBuf; -use std::pin::Pin; use std::process::Child; use std::process::Command; use std::process::Output; @@ -22,8 +20,6 @@ use std::process::Stdio; use std::result::Result; use std::sync::Mutex; use std::sync::MutexGuard; -use std::task::Context; -use std::task::Poll; use tokio::net::TcpStream; use url::Url; @@ -201,29 +197,6 @@ async fn get_tcp_listener_stream( futures::stream::select_all(listeners) } -/// Taken from example in https://github.com/ctz/hyper-rustls/blob/a02ef72a227dcdf102f86e905baa7415c992e8b3/examples/server.rs -struct HyperAcceptor<'a> { - acceptor: Pin< - Box> + 'a>, - >, -} - -impl hyper::server::accept::Accept for HyperAcceptor<'_> { - type Conn = rustls_tokio_stream::TlsStream; - type Error = io::Error; - - fn poll_accept( - mut self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll>> { - Pin::new(&mut self.acceptor).poll_next(cx) - } -} - -#[allow(clippy::non_send_fields_in_send_ty)] -// SAFETY: unsafe trait must have unsafe implementation -unsafe impl std::marker::Send for HyperAcceptor<'_> {} - #[derive(Default)] struct HttpServerCount { count: usize, diff --git a/test_util/src/servers/grpc.rs b/test_util/src/servers/grpc.rs index b957d4c926..08d297a4cd 100644 --- a/test_util/src/servers/grpc.rs +++ b/test_util/src/servers/grpc.rs @@ -1,8 +1,9 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use futures::StreamExt; -use hyper::header::HeaderValue; -use hyper::http; +use h2_04 as h2; +use hyper1::header::HeaderName; +use hyper1::header::HeaderValue; use rustls_tokio_stream::TlsStream; use tokio::net::TcpStream; use tokio::task::LocalSet; @@ -47,7 +48,7 @@ pub async fn h2_grpc_server(h2_grpc_port: u16, h2s_grpc_port: u16) { } async fn handle_request( - mut request: http::Request, + mut request: hyper1::Request, mut respond: h2::server::SendResponse, ) -> Result<(), anyhow::Error> { let body = request.body_mut(); @@ -58,17 +59,17 @@ pub async fn h2_grpc_server(h2_grpc_port: u16, h2s_grpc_port: u16) { let maybe_recv_trailers = body.trailers().await?; - let response = http::Response::new(()); + let response = hyper1::Response::new(()); let mut send = respond.send_response(response, false)?; send.send_data(bytes::Bytes::from_static(b"hello "), false)?; send.send_data(bytes::Bytes::from_static(b"world\n"), false)?; - let mut trailers = http::HeaderMap::new(); + let mut trailers = hyper1::HeaderMap::new(); trailers.insert( - http::HeaderName::from_static("abc"), + HeaderName::from_static("abc"), HeaderValue::from_static("def"), ); trailers.insert( - http::HeaderName::from_static("opr"), + HeaderName::from_static("opr"), HeaderValue::from_static("stv"), ); if let Some(recv_trailers) = maybe_recv_trailers {