summaryrefslogtreecommitdiff
path: root/runtime/ops/http.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-03-19 14:21:49 +0100
committerGitHub <noreply@github.com>2022-03-19 14:21:49 +0100
commit52a6e9ef4ad63c06504867d60a44840c62b7a0cd (patch)
tree6e6573e9e226daeef84eaf41bfbef5d2f7b05d9a /runtime/ops/http.rs
parente55dee7fd894f705a0268a4734b00197021f0617 (diff)
feat(ext/net): Deno.upgradeHttp handles unix connections (#13987)
Diffstat (limited to 'runtime/ops/http.rs')
-rw-r--r--runtime/ops/http.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs
index 1e2bd66ec..702302c07 100644
--- a/runtime/ops/http.rs
+++ b/runtime/ops/http.rs
@@ -14,11 +14,14 @@ use deno_http::http_create_conn_resource;
use deno_http::HttpRequestReader;
use deno_http::HttpStreamResource;
use deno_net::io::TcpStreamResource;
+use deno_net::io::UnixStreamResource;
use deno_net::ops_tls::TlsStream;
use deno_net::ops_tls::TlsStreamResource;
use hyper::upgrade::Parts;
use serde::Serialize;
use tokio::net::TcpStream;
+#[cfg(unix)]
+use tokio::net::UnixStream;
pub fn init() -> Extension {
Extension::builder()
@@ -121,6 +124,24 @@ async fn op_http_upgrade(
}
Err(transport) => transport,
};
+ #[cfg(unix)]
+ let transport = match transport.downcast::<UnixStream>() {
+ Ok(Parts {
+ io: unix_stream,
+ read_buf,
+ ..
+ }) => {
+ return Ok(HttpUpgradeResult {
+ conn_type: "unix",
+ conn_rid: state
+ .borrow_mut()
+ .resource_table
+ .add(UnixStreamResource::new(unix_stream.into_split())),
+ read_buf: read_buf.to_vec().into(),
+ });
+ }
+ Err(transport) => transport,
+ };
match transport.downcast::<TlsStream>() {
Ok(Parts {
io: tls_stream,