summaryrefslogtreecommitdiff
path: root/ext/http/01_http.js
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 /ext/http/01_http.js
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 'ext/http/01_http.js')
-rw-r--r--ext/http/01_http.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/http/01_http.js b/ext/http/01_http.js
index 7dfe86a75..6df26d09f 100644
--- a/ext/http/01_http.js
+++ b/ext/http/01_http.js
@@ -13,6 +13,7 @@
newInnerRequest,
newInnerResponse,
fromInnerResponse,
+ _flash,
} = window.__bootstrap.fetch;
const core = window.Deno.core;
const { BadResourcePrototype, InterruptedPrototype, ops } = core;
@@ -475,6 +476,20 @@
}
function upgradeHttp(req) {
+ if (req[_flash]) {
+ // NOTE(bartlomieju):
+ // Access these fields so they are cached on `req` object, otherwise
+ // they wouldn't be available after the connection gets upgraded.
+ req.url;
+ req.method;
+ req.headers;
+
+ const { serverId, streamRid } = req[_flash];
+ const connRid = core.ops.op_flash_upgrade_http(streamRid, serverId);
+ // TODO(@littledivy): return already read first packet too.
+ return [new TcpConn(connRid), new Uint8Array()];
+ }
+
req[_deferred] = new Deferred();
return req[_deferred].promise;
}
@@ -483,5 +498,6 @@
HttpConn,
upgradeWebSocket,
upgradeHttp,
+ _ws,
};
})(this);