diff options
Diffstat (limited to 'ext/http/01_http.js')
-rw-r--r-- | ext/http/01_http.js | 16 |
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); |