summaryrefslogtreecommitdiff
path: root/runtime/ops/http.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-08-18 17:35:02 +0530
committerGitHub <noreply@github.com>2022-08-18 17:35:02 +0530
commitcd21cff29942f24ba7d38287186cce64d0e84e56 (patch)
treee663eff884526ee762ae9141a3cf5a0f6967a84e /runtime/ops/http.rs
parent0b0843e4a54d7c1ddf293ac1ccee2479b69a5ba9 (diff)
feat(ext/flash): An optimized http/1.1 server (#15405)
Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com> Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl> Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'runtime/ops/http.rs')
-rw-r--r--runtime/ops/http.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs
index 67d939976..7a58da361 100644
--- a/runtime/ops/http.rs
+++ b/runtime/ops/http.rs
@@ -27,7 +27,11 @@ use tokio::net::UnixStream;
pub fn init() -> Extension {
Extension::builder()
- .ops(vec![op_http_start::decl(), op_http_upgrade::decl()])
+ .ops(vec![
+ op_http_start::decl(),
+ op_http_upgrade::decl(),
+ op_flash_upgrade_http::decl(),
+ ])
.build()
}
@@ -78,6 +82,23 @@ fn op_http_start(
Err(bad_resource_id())
}
+#[op]
+fn op_flash_upgrade_http(
+ state: &mut OpState,
+ token: u32,
+ server_id: u32,
+) -> Result<deno_core::ResourceId, AnyError> {
+ let flash_ctx = state.borrow_mut::<deno_flash::FlashContext>();
+ let ctx = flash_ctx.servers.get_mut(&server_id).unwrap();
+
+ let tcp_stream = deno_flash::detach_socket(ctx, token)?;
+ Ok(
+ state
+ .resource_table
+ .add(TcpStreamResource::new(tcp_stream.into_split())),
+ )
+}
+
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HttpUpgradeResult {