diff options
Diffstat (limited to 'ext/fetch')
-rw-r--r-- | ext/fetch/20_headers.js | 21 | ||||
-rw-r--r-- | ext/fetch/22_body.js | 43 | ||||
-rw-r--r-- | ext/fetch/22_http_client.js | 7 | ||||
-rw-r--r-- | ext/fetch/23_request.js | 27 | ||||
-rw-r--r-- | ext/fetch/26_fetch.js | 44 | ||||
-rw-r--r-- | ext/fetch/27_eventsource.js | 36 |
6 files changed, 94 insertions, 84 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index cdc2f44b7..3ee9d9184 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -9,16 +9,6 @@ /// <reference path="./lib.deno_fetch.d.ts" /> /// <reference lib="esnext" /> -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { - byteLowerCase, - collectHttpQuotedString, - collectSequenceOfCodepoints, - HTTP_TAB_OR_SPACE_PREFIX_RE, - HTTP_TAB_OR_SPACE_SUFFIX_RE, - HTTP_TOKEN_CODE_POINT_RE, - httpTrim, -} from "ext:deno_web/00_infra.js"; import { primordials } from "ext:core/mod.js"; const { ArrayIsArray, @@ -38,6 +28,17 @@ const { TypeError, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { + byteLowerCase, + collectHttpQuotedString, + collectSequenceOfCodepoints, + HTTP_TAB_OR_SPACE_PREFIX_RE, + HTTP_TAB_OR_SPACE_SUFFIX_RE, + HTTP_TOKEN_CODE_POINT_RE, + httpTrim, +} from "ext:deno_web/00_infra.js"; + const _headerList = Symbol("header list"); const _iterableHeaders = Symbol("iterable headers"); const _iterableHeadersCache = Symbol("iterable headers cache"); diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index 2d633ae39..e16fd4c54 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -12,6 +12,28 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; +const { + isAnyArrayBuffer, + isArrayBuffer, +} = core; +const { + ArrayBufferIsView, + ArrayPrototypeMap, + DataViewPrototypeGetBuffer, + DataViewPrototypeGetByteLength, + DataViewPrototypeGetByteOffset, + JSONParse, + ObjectDefineProperties, + ObjectPrototypeIsPrototypeOf, + TypedArrayPrototypeGetBuffer, + TypedArrayPrototypeGetByteLength, + TypedArrayPrototypeGetByteOffset, + TypedArrayPrototypeGetSymbolToStringTag, + TypedArrayPrototypeSlice, + TypeError, + Uint8Array, +} = primordials; + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { parseUrlEncoded, @@ -36,27 +58,6 @@ import { readableStreamTee, readableStreamThrowIfErrored, } from "ext:deno_web/06_streams.js"; -const { - ArrayBufferIsView, - ArrayPrototypeMap, - DataViewPrototypeGetBuffer, - DataViewPrototypeGetByteLength, - DataViewPrototypeGetByteOffset, - JSONParse, - ObjectDefineProperties, - ObjectPrototypeIsPrototypeOf, - TypedArrayPrototypeGetBuffer, - TypedArrayPrototypeGetByteLength, - TypedArrayPrototypeGetByteOffset, - TypedArrayPrototypeGetSymbolToStringTag, - TypedArrayPrototypeSlice, - TypeError, - Uint8Array, -} = primordials; -const { - isAnyArrayBuffer, - isArrayBuffer, -} = core; /** * @param {Uint8Array | string} chunk diff --git a/ext/fetch/22_http_client.js b/ext/fetch/22_http_client.js index dd5b99bfe..b6945e674 100644 --- a/ext/fetch/22_http_client.js +++ b/ext/fetch/22_http_client.js @@ -11,8 +11,11 @@ /// <reference lib="esnext" /> import { core } from "ext:core/mod.js"; -const ops = core.ops; + import { SymbolDispose } from "ext:deno_web/00_infra.js"; +const { + op_fetch_custom_client, +} = core.ensureFastOps(); /** * @param {Deno.CreateHttpClientOptions} options @@ -21,7 +24,7 @@ import { SymbolDispose } from "ext:deno_web/00_infra.js"; function createHttpClient(options) { options.caCerts ??= []; return new HttpClient( - ops.op_fetch_custom_client( + op_fetch_custom_client( options, ), ); diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 0f763234a..8ca92ca72 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -9,6 +9,20 @@ /// <reference path="./lib.deno_fetch.d.ts" /> /// <reference lib="esnext" /> +import { primordials } from "ext:core/mod.js"; +const { + ArrayPrototypeMap, + ArrayPrototypeSlice, + ArrayPrototypeSplice, + ObjectKeys, + ObjectPrototypeIsPrototypeOf, + RegExpPrototypeExec, + StringPrototypeStartsWith, + Symbol, + SymbolFor, + TypeError, +} = primordials; + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { assert } from "ext:deno_web/00_infra.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; @@ -30,19 +44,6 @@ import { } from "ext:deno_fetch/20_headers.js"; import { HttpClientPrototype } from "ext:deno_fetch/22_http_client.js"; import * as abortSignal from "ext:deno_web/03_abort_signal.js"; -import { primordials } from "ext:core/mod.js"; -const { - ArrayPrototypeMap, - ArrayPrototypeSlice, - ArrayPrototypeSplice, - ObjectKeys, - ObjectPrototypeIsPrototypeOf, - RegExpPrototypeExec, - StringPrototypeStartsWith, - Symbol, - SymbolFor, - TypeError, -} = primordials; const _request = Symbol("request"); const _headers = Symbol("headers"); diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index b53013e49..154e2bcd3 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -11,10 +11,29 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; const { + op_fetch, op_fetch_send, + op_wasm_streaming_feed, + op_wasm_streaming_set_url, } = core.ensureFastOps(); +const { + ArrayPrototypePush, + ArrayPrototypeSplice, + ArrayPrototypeFilter, + ArrayPrototypeIncludes, + Error, + ObjectPrototypeIsPrototypeOf, + Promise, + PromisePrototypeThen, + PromisePrototypeCatch, + SafeArrayIterator, + String, + StringPrototypeStartsWith, + StringPrototypeToLowerCase, + TypeError, + TypedArrayPrototypeGetSymbolToStringTag, +} = primordials; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { byteLowerCase } from "ext:deno_web/00_infra.js"; @@ -36,23 +55,6 @@ import { toInnerResponse, } from "ext:deno_fetch/23_response.js"; import * as abortSignal from "ext:deno_web/03_abort_signal.js"; -const { - ArrayPrototypePush, - ArrayPrototypeSplice, - ArrayPrototypeFilter, - ArrayPrototypeIncludes, - Error, - ObjectPrototypeIsPrototypeOf, - Promise, - PromisePrototypeThen, - PromisePrototypeCatch, - SafeArrayIterator, - String, - StringPrototypeStartsWith, - StringPrototypeToLowerCase, - TypeError, - TypedArrayPrototypeGetSymbolToStringTag, -} = primordials; const REQUEST_BODY_HEADER_NAMES = [ "content-encoding", @@ -147,7 +149,7 @@ async function mainFetch(req, recursive, terminator) { } } - const { requestRid, cancelHandleRid } = ops.op_fetch( + const { requestRid, cancelHandleRid } = op_fetch( req.method, req.currentUrl(), req.headerList, @@ -448,7 +450,7 @@ function handleWasmStreaming(source, rid) { } // Pass the resolved URL to v8. - ops.op_wasm_streaming_set_url(rid, res.url); + op_wasm_streaming_set_url(rid, res.url); if (res.body !== null) { // 2.6. @@ -460,7 +462,7 @@ function handleWasmStreaming(source, rid) { while (true) { const { value: chunk, done } = await reader.read(); if (done) break; - ops.op_wasm_streaming_feed(rid, chunk); + op_wasm_streaming_feed(rid, chunk); } })(), // 2.7 diff --git a/ext/fetch/27_eventsource.js b/ext/fetch/27_eventsource.js index fa1d928e5..2e82fbc7f 100644 --- a/ext/fetch/27_eventsource.js +++ b/ext/fetch/27_eventsource.js @@ -3,22 +3,9 @@ /// <reference path="../../core/internal.d.ts" /> import { core, primordials } from "ext:core/mod.js"; - -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -import { URL } from "ext:deno_url/00_url.js"; -import { DOMException } from "ext:deno_web/01_dom_exception.js"; -import { - defineEventHandler, - EventTarget, - setIsTrusted, -} from "ext:deno_web/02_event.js"; -import { TransformStream } from "ext:deno_web/06_streams.js"; -import { TextDecoderStream } from "ext:deno_web/08_text_encoding.js"; -import { getLocationHref } from "ext:deno_web/12_location.js"; -import { newInnerRequest } from "ext:deno_fetch/23_request.js"; -import { mainFetch } from "ext:deno_fetch/26_fetch.js"; - +const { + op_utf8_to_byte_string, +} = core.ensureFastOps(); const { ArrayPrototypeFind, Number, @@ -38,6 +25,21 @@ const { SymbolFor, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +import { URL } from "ext:deno_url/00_url.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; +import { + defineEventHandler, + EventTarget, + setIsTrusted, +} from "ext:deno_web/02_event.js"; +import { TransformStream } from "ext:deno_web/06_streams.js"; +import { TextDecoderStream } from "ext:deno_web/08_text_encoding.js"; +import { getLocationHref } from "ext:deno_web/12_location.js"; +import { newInnerRequest } from "ext:deno_fetch/23_request.js"; +import { mainFetch } from "ext:deno_fetch/26_fetch.js"; + // Copied from https://github.com/denoland/deno_std/blob/e0753abe0c8602552862a568348c046996709521/streams/text_line_stream.ts#L20-L74 export class TextLineStream extends TransformStream { #allowCR; @@ -205,7 +207,7 @@ class EventSource extends EventTarget { ["accept", "text/event-stream"], [ "Last-Event-Id", - core.ops.op_utf8_to_byte_string(lastEventIDValueCopy), + op_utf8_to_byte_string(lastEventIDValueCopy), ], ], null, |