diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-01-27 16:27:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 16:27:22 +0100 |
commit | f248e6f1778dc26db91d3322de2ecca5d1aa9866 (patch) | |
tree | 46b1ff59091cc8d31ff67427173d3a0148734007 /ext/fetch/26_fetch.js | |
parent | 382a978859a7a7a4351542be818bb2e59523429c (diff) |
Revert "refactor: update runtime code for primordial checks for "instanceof" (#13497)" (#13511)
This reverts commit 884143218fad0e18f7553aaf079d52de703f7601.
Diffstat (limited to 'ext/fetch/26_fetch.js')
-rw-r--r-- | ext/fetch/26_fetch.js | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 0c58bbf97..c6fc9197b 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -15,9 +15,7 @@ const core = window.Deno.core; const webidl = window.__bootstrap.webidl; const { byteLowerCase } = window.__bootstrap.infra; - const { BlobPrototype } = window.__bootstrap.file; - const { errorReadableStream, ReadableStreamPrototype } = - window.__bootstrap.streams; + const { errorReadableStream } = window.__bootstrap.streams; const { InnerBody, extractBody } = window.__bootstrap.fetchBody; const { toInnerRequest, @@ -34,7 +32,6 @@ ArrayPrototypeSplice, ArrayPrototypeFilter, ArrayPrototypeIncludes, - ObjectPrototypeIsPrototypeOf, Promise, PromisePrototypeThen, PromisePrototypeCatch, @@ -44,7 +41,6 @@ TypedArrayPrototypeSubarray, TypeError, Uint8Array, - Uint8ArrayPrototype, WeakMap, WeakMapPrototypeDelete, WeakMapPrototypeGet, @@ -176,16 +172,8 @@ let reqBody = null; if (req.body !== null) { - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - req.body.streamOrStatic, - ) - ) { - if ( - req.body.length === null || - ObjectPrototypeIsPrototypeOf(BlobPrototype, req.body.source) - ) { + if (req.body.streamOrStatic instanceof ReadableStream) { + if (req.body.length === null || req.body.source instanceof Blob) { reqBody = req.body.stream; } else { const reader = req.body.stream.getReader(); @@ -208,19 +196,14 @@ } } - const { requestRid, requestBodyRid, cancelHandleRid } = opFetch( - { - method: req.method, - url: req.currentUrl(), - headers: req.headerList, - clientRid: req.clientRid, - hasBody: reqBody !== null, - bodyLength: req.body?.length, - }, - ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, reqBody) - ? reqBody - : null, - ); + const { requestRid, requestBodyRid, cancelHandleRid } = opFetch({ + method: req.method, + url: req.currentUrl(), + headers: req.headerList, + clientRid: req.clientRid, + hasBody: reqBody !== null, + bodyLength: req.body?.length, + }, reqBody instanceof Uint8Array ? reqBody : null); function onAbort() { if (cancelHandleRid !== null) { @@ -233,10 +216,7 @@ terminator[abortSignal.add](onAbort); if (requestBodyRid !== null) { - if ( - reqBody === null || - !ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, reqBody) - ) { + if (reqBody === null || !(reqBody instanceof ReadableStream)) { throw new TypeError("Unreachable"); } const reader = reqBody.getReader(); @@ -251,7 +231,7 @@ }, ); if (done) break; - if (!ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, value)) { + if (!(value instanceof Uint8Array)) { await reader.cancel("value not a Uint8Array"); break; } |