diff --git a/Cargo.lock b/Cargo.lock index 0372622ac2..121e4a45a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1412,6 +1412,7 @@ dependencies = [ "fastwebsockets", "http", "hyper 0.14.26", + "once_cell", "serde", "tokio", "tokio-rustls", diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index 900a956f49..93634ae3e2 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -73,13 +73,13 @@ type Request = hyper1::Request; type Response = hyper1::Response; static USE_WRITEV: Lazy = Lazy::new(|| { - let disable_writev = std::env::var("DENO_HYPER_USE_WRITEV").ok(); + let enable = std::env::var("DENO_USE_WRITEV").ok(); - if let Some(val) = disable_writev { - return val != "0"; + if let Some(val) = enable { + return !val.is_empty(); } - true + false }); /// All HTTP/2 connections start with this byte string. diff --git a/ext/websocket/Cargo.toml b/ext/websocket/Cargo.toml index 1ac465f698..324a2b1a43 100644 --- a/ext/websocket/Cargo.toml +++ b/ext/websocket/Cargo.toml @@ -21,6 +21,7 @@ deno_tls.workspace = true fastwebsockets = { workspace = true, features = ["upgrade"] } http.workspace = true hyper = { workspace = true, features = ["backports"] } +once_cell.workspace = true serde.workspace = true tokio.workspace = true tokio-rustls.workspace = true diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index af987c1e4b..b492be0c02 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -27,6 +27,7 @@ use http::Method; use http::Request; use http::Uri; use hyper::Body; +use once_cell::sync::Lazy; use serde::Serialize; use std::borrow::Cow; use std::cell::Cell; @@ -50,9 +51,18 @@ use fastwebsockets::Frame; use fastwebsockets::OpCode; use fastwebsockets::Role; use fastwebsockets::WebSocket; - mod stream; +static USE_WRITEV: Lazy = Lazy::new(|| { + let enable = std::env::var("DENO_USE_WRITEV").ok(); + + if let Some(val) = enable { + return !val.is_empty(); + } + + false +}); + #[derive(Clone)] pub struct WsRootStoreProvider(Option>); @@ -360,7 +370,7 @@ pub fn ws_create_server_stream( ), Role::Server, ); - ws.set_writev(true); + ws.set_writev(*USE_WRITEV); ws.set_auto_close(true); ws.set_auto_pong(true);