deepv-code 1.0.182 → 1.0.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dvcode.js +757 -753
- package/package.json +1 -1
- package/bundle/assets/help/README.md +0 -113
- package/bundle/assets/sounds/README.md +0 -74
- package/bundle/node_modules/undici/LICENSE +0 -21
- package/bundle/node_modules/undici/README.md +0 -472
- package/bundle/node_modules/undici/docs/docs/api/Agent.md +0 -83
- package/bundle/node_modules/undici/docs/docs/api/BalancedPool.md +0 -99
- package/bundle/node_modules/undici/docs/docs/api/CacheStorage.md +0 -30
- package/bundle/node_modules/undici/docs/docs/api/CacheStore.md +0 -151
- package/bundle/node_modules/undici/docs/docs/api/Client.md +0 -281
- package/bundle/node_modules/undici/docs/docs/api/ClientStats.md +0 -27
- package/bundle/node_modules/undici/docs/docs/api/Connector.md +0 -115
- package/bundle/node_modules/undici/docs/docs/api/ContentType.md +0 -57
- package/bundle/node_modules/undici/docs/docs/api/Cookies.md +0 -101
- package/bundle/node_modules/undici/docs/docs/api/Debug.md +0 -62
- package/bundle/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +0 -204
- package/bundle/node_modules/undici/docs/docs/api/Dispatcher.md +0 -1200
- package/bundle/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +0 -159
- package/bundle/node_modules/undici/docs/docs/api/Errors.md +0 -49
- package/bundle/node_modules/undici/docs/docs/api/EventSource.md +0 -45
- package/bundle/node_modules/undici/docs/docs/api/Fetch.md +0 -52
- package/bundle/node_modules/undici/docs/docs/api/H2CClient.md +0 -262
- package/bundle/node_modules/undici/docs/docs/api/MockAgent.md +0 -603
- package/bundle/node_modules/undici/docs/docs/api/MockCallHistory.md +0 -197
- package/bundle/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +0 -43
- package/bundle/node_modules/undici/docs/docs/api/MockClient.md +0 -77
- package/bundle/node_modules/undici/docs/docs/api/MockErrors.md +0 -12
- package/bundle/node_modules/undici/docs/docs/api/MockPool.md +0 -548
- package/bundle/node_modules/undici/docs/docs/api/Pool.md +0 -84
- package/bundle/node_modules/undici/docs/docs/api/PoolStats.md +0 -35
- package/bundle/node_modules/undici/docs/docs/api/ProxyAgent.md +0 -227
- package/bundle/node_modules/undici/docs/docs/api/RedirectHandler.md +0 -96
- package/bundle/node_modules/undici/docs/docs/api/RetryAgent.md +0 -45
- package/bundle/node_modules/undici/docs/docs/api/RetryHandler.md +0 -117
- package/bundle/node_modules/undici/docs/docs/api/Util.md +0 -25
- package/bundle/node_modules/undici/docs/docs/api/WebSocket.md +0 -85
- package/bundle/node_modules/undici/docs/docs/api/api-lifecycle.md +0 -91
- package/bundle/node_modules/undici/docs/docs/best-practices/client-certificate.md +0 -64
- package/bundle/node_modules/undici/docs/docs/best-practices/mocking-request.md +0 -190
- package/bundle/node_modules/undici/docs/docs/best-practices/proxy.md +0 -127
- package/bundle/node_modules/undici/docs/docs/best-practices/writing-tests.md +0 -20
- package/bundle/node_modules/undici/index-fetch.js +0 -35
- package/bundle/node_modules/undici/index.d.ts +0 -3
- package/bundle/node_modules/undici/index.js +0 -183
- package/bundle/node_modules/undici/lib/api/abort-signal.js +0 -59
- package/bundle/node_modules/undici/lib/api/api-connect.js +0 -110
- package/bundle/node_modules/undici/lib/api/api-pipeline.js +0 -252
- package/bundle/node_modules/undici/lib/api/api-request.js +0 -199
- package/bundle/node_modules/undici/lib/api/api-stream.js +0 -209
- package/bundle/node_modules/undici/lib/api/api-upgrade.js +0 -110
- package/bundle/node_modules/undici/lib/api/index.js +0 -7
- package/bundle/node_modules/undici/lib/api/readable.js +0 -558
- package/bundle/node_modules/undici/lib/api/util.js +0 -95
- package/bundle/node_modules/undici/lib/cache/memory-cache-store.js +0 -234
- package/bundle/node_modules/undici/lib/cache/sqlite-cache-store.js +0 -461
- package/bundle/node_modules/undici/lib/core/connect.js +0 -164
- package/bundle/node_modules/undici/lib/core/constants.js +0 -143
- package/bundle/node_modules/undici/lib/core/diagnostics.js +0 -196
- package/bundle/node_modules/undici/lib/core/errors.js +0 -244
- package/bundle/node_modules/undici/lib/core/request.js +0 -397
- package/bundle/node_modules/undici/lib/core/symbols.js +0 -68
- package/bundle/node_modules/undici/lib/core/tree.js +0 -160
- package/bundle/node_modules/undici/lib/core/util.js +0 -988
- package/bundle/node_modules/undici/lib/dispatcher/agent.js +0 -135
- package/bundle/node_modules/undici/lib/dispatcher/balanced-pool.js +0 -206
- package/bundle/node_modules/undici/lib/dispatcher/client-h1.js +0 -1615
- package/bundle/node_modules/undici/lib/dispatcher/client-h2.js +0 -798
- package/bundle/node_modules/undici/lib/dispatcher/client.js +0 -614
- package/bundle/node_modules/undici/lib/dispatcher/dispatcher-base.js +0 -161
- package/bundle/node_modules/undici/lib/dispatcher/dispatcher.js +0 -48
- package/bundle/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +0 -151
- package/bundle/node_modules/undici/lib/dispatcher/fixed-queue.js +0 -159
- package/bundle/node_modules/undici/lib/dispatcher/h2c-client.js +0 -122
- package/bundle/node_modules/undici/lib/dispatcher/pool-base.js +0 -191
- package/bundle/node_modules/undici/lib/dispatcher/pool.js +0 -118
- package/bundle/node_modules/undici/lib/dispatcher/proxy-agent.js +0 -275
- package/bundle/node_modules/undici/lib/dispatcher/retry-agent.js +0 -35
- package/bundle/node_modules/undici/lib/global.js +0 -32
- package/bundle/node_modules/undici/lib/handler/cache-handler.js +0 -448
- package/bundle/node_modules/undici/lib/handler/cache-revalidation-handler.js +0 -124
- package/bundle/node_modules/undici/lib/handler/decorator-handler.js +0 -67
- package/bundle/node_modules/undici/lib/handler/redirect-handler.js +0 -227
- package/bundle/node_modules/undici/lib/handler/retry-handler.js +0 -342
- package/bundle/node_modules/undici/lib/handler/unwrap-handler.js +0 -96
- package/bundle/node_modules/undici/lib/handler/wrap-handler.js +0 -95
- package/bundle/node_modules/undici/lib/interceptor/cache.js +0 -372
- package/bundle/node_modules/undici/lib/interceptor/dns.js +0 -432
- package/bundle/node_modules/undici/lib/interceptor/dump.js +0 -111
- package/bundle/node_modules/undici/lib/interceptor/redirect.js +0 -21
- package/bundle/node_modules/undici/lib/interceptor/response-error.js +0 -95
- package/bundle/node_modules/undici/lib/interceptor/retry.js +0 -19
- package/bundle/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/bundle/node_modules/undici/lib/llhttp/constants.d.ts +0 -97
- package/bundle/node_modules/undici/lib/llhttp/constants.js +0 -498
- package/bundle/node_modules/undici/lib/llhttp/constants.js.map +0 -1
- package/bundle/node_modules/undici/lib/llhttp/llhttp-wasm.js +0 -15
- package/bundle/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +0 -15
- package/bundle/node_modules/undici/lib/llhttp/utils.d.ts +0 -2
- package/bundle/node_modules/undici/lib/llhttp/utils.js +0 -15
- package/bundle/node_modules/undici/lib/llhttp/utils.js.map +0 -1
- package/bundle/node_modules/undici/lib/mock/mock-agent.js +0 -224
- package/bundle/node_modules/undici/lib/mock/mock-call-history.js +0 -248
- package/bundle/node_modules/undici/lib/mock/mock-client.js +0 -64
- package/bundle/node_modules/undici/lib/mock/mock-errors.js +0 -19
- package/bundle/node_modules/undici/lib/mock/mock-interceptor.js +0 -209
- package/bundle/node_modules/undici/lib/mock/mock-pool.js +0 -64
- package/bundle/node_modules/undici/lib/mock/mock-symbols.js +0 -31
- package/bundle/node_modules/undici/lib/mock/mock-utils.js +0 -433
- package/bundle/node_modules/undici/lib/mock/pending-interceptors-formatter.js +0 -43
- package/bundle/node_modules/undici/lib/util/cache.js +0 -368
- package/bundle/node_modules/undici/lib/util/date.js +0 -259
- package/bundle/node_modules/undici/lib/util/stats.js +0 -32
- package/bundle/node_modules/undici/lib/util/timers.js +0 -423
- package/bundle/node_modules/undici/lib/web/cache/cache.js +0 -862
- package/bundle/node_modules/undici/lib/web/cache/cachestorage.js +0 -152
- package/bundle/node_modules/undici/lib/web/cache/util.js +0 -45
- package/bundle/node_modules/undici/lib/web/cookies/constants.js +0 -12
- package/bundle/node_modules/undici/lib/web/cookies/index.js +0 -199
- package/bundle/node_modules/undici/lib/web/cookies/parse.js +0 -322
- package/bundle/node_modules/undici/lib/web/cookies/util.js +0 -282
- package/bundle/node_modules/undici/lib/web/eventsource/eventsource-stream.js +0 -399
- package/bundle/node_modules/undici/lib/web/eventsource/eventsource.js +0 -484
- package/bundle/node_modules/undici/lib/web/eventsource/util.js +0 -37
- package/bundle/node_modules/undici/lib/web/fetch/LICENSE +0 -21
- package/bundle/node_modules/undici/lib/web/fetch/body.js +0 -532
- package/bundle/node_modules/undici/lib/web/fetch/constants.js +0 -131
- package/bundle/node_modules/undici/lib/web/fetch/data-url.js +0 -744
- package/bundle/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +0 -46
- package/bundle/node_modules/undici/lib/web/fetch/formdata-parser.js +0 -501
- package/bundle/node_modules/undici/lib/web/fetch/formdata.js +0 -263
- package/bundle/node_modules/undici/lib/web/fetch/global.js +0 -40
- package/bundle/node_modules/undici/lib/web/fetch/headers.js +0 -719
- package/bundle/node_modules/undici/lib/web/fetch/index.js +0 -2258
- package/bundle/node_modules/undici/lib/web/fetch/request.js +0 -1099
- package/bundle/node_modules/undici/lib/web/fetch/response.js +0 -636
- package/bundle/node_modules/undici/lib/web/fetch/util.js +0 -1782
- package/bundle/node_modules/undici/lib/web/fetch/webidl.js +0 -740
- package/bundle/node_modules/undici/lib/web/websocket/connection.js +0 -325
- package/bundle/node_modules/undici/lib/web/websocket/constants.js +0 -126
- package/bundle/node_modules/undici/lib/web/websocket/events.js +0 -331
- package/bundle/node_modules/undici/lib/web/websocket/frame.js +0 -138
- package/bundle/node_modules/undici/lib/web/websocket/permessage-deflate.js +0 -70
- package/bundle/node_modules/undici/lib/web/websocket/receiver.js +0 -454
- package/bundle/node_modules/undici/lib/web/websocket/sender.js +0 -109
- package/bundle/node_modules/undici/lib/web/websocket/stream/websocketerror.js +0 -83
- package/bundle/node_modules/undici/lib/web/websocket/stream/websocketstream.js +0 -485
- package/bundle/node_modules/undici/lib/web/websocket/util.js +0 -338
- package/bundle/node_modules/undici/lib/web/websocket/websocket.js +0 -686
- package/bundle/node_modules/undici/package.json +0 -149
- package/bundle/node_modules/undici/scripts/strip-comments.js +0 -10
- package/bundle/node_modules/undici/types/README.md +0 -6
- package/bundle/node_modules/undici/types/agent.d.ts +0 -35
- package/bundle/node_modules/undici/types/api.d.ts +0 -43
- package/bundle/node_modules/undici/types/balanced-pool.d.ts +0 -29
- package/bundle/node_modules/undici/types/cache-interceptor.d.ts +0 -172
- package/bundle/node_modules/undici/types/cache.d.ts +0 -36
- package/bundle/node_modules/undici/types/client-stats.d.ts +0 -15
- package/bundle/node_modules/undici/types/client.d.ts +0 -110
- package/bundle/node_modules/undici/types/connector.d.ts +0 -34
- package/bundle/node_modules/undici/types/content-type.d.ts +0 -21
- package/bundle/node_modules/undici/types/cookies.d.ts +0 -30
- package/bundle/node_modules/undici/types/diagnostics-channel.d.ts +0 -66
- package/bundle/node_modules/undici/types/dispatcher.d.ts +0 -281
- package/bundle/node_modules/undici/types/env-http-proxy-agent.d.ts +0 -21
- package/bundle/node_modules/undici/types/errors.d.ts +0 -171
- package/bundle/node_modules/undici/types/eventsource.d.ts +0 -61
- package/bundle/node_modules/undici/types/fetch.d.ts +0 -210
- package/bundle/node_modules/undici/types/formdata.d.ts +0 -108
- package/bundle/node_modules/undici/types/global-dispatcher.d.ts +0 -9
- package/bundle/node_modules/undici/types/global-origin.d.ts +0 -7
- package/bundle/node_modules/undici/types/h2c-client.d.ts +0 -75
- package/bundle/node_modules/undici/types/handlers.d.ts +0 -15
- package/bundle/node_modules/undici/types/header.d.ts +0 -160
- package/bundle/node_modules/undici/types/index.d.ts +0 -75
- package/bundle/node_modules/undici/types/interceptors.d.ts +0 -34
- package/bundle/node_modules/undici/types/mock-agent.d.ts +0 -68
- package/bundle/node_modules/undici/types/mock-call-history.d.ts +0 -111
- package/bundle/node_modules/undici/types/mock-client.d.ts +0 -25
- package/bundle/node_modules/undici/types/mock-errors.d.ts +0 -12
- package/bundle/node_modules/undici/types/mock-interceptor.d.ts +0 -93
- package/bundle/node_modules/undici/types/mock-pool.d.ts +0 -25
- package/bundle/node_modules/undici/types/patch.d.ts +0 -29
- package/bundle/node_modules/undici/types/pool-stats.d.ts +0 -19
- package/bundle/node_modules/undici/types/pool.d.ts +0 -41
- package/bundle/node_modules/undici/types/proxy-agent.d.ts +0 -29
- package/bundle/node_modules/undici/types/readable.d.ts +0 -68
- package/bundle/node_modules/undici/types/retry-agent.d.ts +0 -8
- package/bundle/node_modules/undici/types/retry-handler.d.ts +0 -116
- package/bundle/node_modules/undici/types/util.d.ts +0 -18
- package/bundle/node_modules/undici/types/utility.d.ts +0 -7
- package/bundle/node_modules/undici/types/webidl.d.ts +0 -266
- package/bundle/node_modules/undici/types/websocket.d.ts +0 -184
|
@@ -1,1099 +0,0 @@
|
|
|
1
|
-
/* globals AbortController */
|
|
2
|
-
|
|
3
|
-
'use strict'
|
|
4
|
-
|
|
5
|
-
const { extractBody, mixinBody, cloneBody, bodyUnusable } = require('./body')
|
|
6
|
-
const { Headers, fill: fillHeaders, HeadersList, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList } = require('./headers')
|
|
7
|
-
const { FinalizationRegistry } = require('./dispatcher-weakref')()
|
|
8
|
-
const util = require('../../core/util')
|
|
9
|
-
const nodeUtil = require('node:util')
|
|
10
|
-
const {
|
|
11
|
-
isValidHTTPToken,
|
|
12
|
-
sameOrigin,
|
|
13
|
-
environmentSettingsObject
|
|
14
|
-
} = require('./util')
|
|
15
|
-
const {
|
|
16
|
-
forbiddenMethodsSet,
|
|
17
|
-
corsSafeListedMethodsSet,
|
|
18
|
-
referrerPolicy,
|
|
19
|
-
requestRedirect,
|
|
20
|
-
requestMode,
|
|
21
|
-
requestCredentials,
|
|
22
|
-
requestCache,
|
|
23
|
-
requestDuplex
|
|
24
|
-
} = require('./constants')
|
|
25
|
-
const { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util
|
|
26
|
-
const { webidl } = require('./webidl')
|
|
27
|
-
const { URLSerializer } = require('./data-url')
|
|
28
|
-
const { kConstruct } = require('../../core/symbols')
|
|
29
|
-
const assert = require('node:assert')
|
|
30
|
-
const { getMaxListeners, setMaxListeners, defaultMaxListeners } = require('node:events')
|
|
31
|
-
|
|
32
|
-
const kAbortController = Symbol('abortController')
|
|
33
|
-
|
|
34
|
-
const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
|
|
35
|
-
signal.removeEventListener('abort', abort)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const dependentControllerMap = new WeakMap()
|
|
39
|
-
|
|
40
|
-
let abortSignalHasEventHandlerLeakWarning
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
abortSignalHasEventHandlerLeakWarning = getMaxListeners(new AbortController().signal) > 0
|
|
44
|
-
} catch {
|
|
45
|
-
abortSignalHasEventHandlerLeakWarning = false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function buildAbort (acRef) {
|
|
49
|
-
return abort
|
|
50
|
-
|
|
51
|
-
function abort () {
|
|
52
|
-
const ac = acRef.deref()
|
|
53
|
-
if (ac !== undefined) {
|
|
54
|
-
// Currently, there is a problem with FinalizationRegistry.
|
|
55
|
-
// https://github.com/nodejs/node/issues/49344
|
|
56
|
-
// https://github.com/nodejs/node/issues/47748
|
|
57
|
-
// In the case of abort, the first step is to unregister from it.
|
|
58
|
-
// If the controller can refer to it, it is still registered.
|
|
59
|
-
// It will be removed in the future.
|
|
60
|
-
requestFinalizer.unregister(abort)
|
|
61
|
-
|
|
62
|
-
// Unsubscribe a listener.
|
|
63
|
-
// FinalizationRegistry will no longer be called, so this must be done.
|
|
64
|
-
this.removeEventListener('abort', abort)
|
|
65
|
-
|
|
66
|
-
ac.abort(this.reason)
|
|
67
|
-
|
|
68
|
-
const controllerList = dependentControllerMap.get(ac.signal)
|
|
69
|
-
|
|
70
|
-
if (controllerList !== undefined) {
|
|
71
|
-
if (controllerList.size !== 0) {
|
|
72
|
-
for (const ref of controllerList) {
|
|
73
|
-
const ctrl = ref.deref()
|
|
74
|
-
if (ctrl !== undefined) {
|
|
75
|
-
ctrl.abort(this.reason)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
controllerList.clear()
|
|
79
|
-
}
|
|
80
|
-
dependentControllerMap.delete(ac.signal)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let patchMethodWarning = false
|
|
87
|
-
|
|
88
|
-
// https://fetch.spec.whatwg.org/#request-class
|
|
89
|
-
class Request {
|
|
90
|
-
/** @type {AbortSignal} */
|
|
91
|
-
#signal
|
|
92
|
-
|
|
93
|
-
/** @type {import('../../dispatcher/dispatcher')} */
|
|
94
|
-
#dispatcher
|
|
95
|
-
|
|
96
|
-
/** @type {Headers} */
|
|
97
|
-
#headers
|
|
98
|
-
|
|
99
|
-
#state
|
|
100
|
-
|
|
101
|
-
// https://fetch.spec.whatwg.org/#dom-request
|
|
102
|
-
constructor (input, init = undefined) {
|
|
103
|
-
webidl.util.markAsUncloneable(this)
|
|
104
|
-
|
|
105
|
-
if (input === kConstruct) {
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const prefix = 'Request constructor'
|
|
110
|
-
webidl.argumentLengthCheck(arguments, 1, prefix)
|
|
111
|
-
|
|
112
|
-
input = webidl.converters.RequestInfo(input, prefix, 'input')
|
|
113
|
-
init = webidl.converters.RequestInit(init, prefix, 'init')
|
|
114
|
-
|
|
115
|
-
// 1. Let request be null.
|
|
116
|
-
let request = null
|
|
117
|
-
|
|
118
|
-
// 2. Let fallbackMode be null.
|
|
119
|
-
let fallbackMode = null
|
|
120
|
-
|
|
121
|
-
// 3. Let baseURL be this’s relevant settings object’s API base URL.
|
|
122
|
-
const baseUrl = environmentSettingsObject.settingsObject.baseUrl
|
|
123
|
-
|
|
124
|
-
// 4. Let signal be null.
|
|
125
|
-
let signal = null
|
|
126
|
-
|
|
127
|
-
// 5. If input is a string, then:
|
|
128
|
-
if (typeof input === 'string') {
|
|
129
|
-
this.#dispatcher = init.dispatcher
|
|
130
|
-
|
|
131
|
-
// 1. Let parsedURL be the result of parsing input with baseURL.
|
|
132
|
-
// 2. If parsedURL is failure, then throw a TypeError.
|
|
133
|
-
let parsedURL
|
|
134
|
-
try {
|
|
135
|
-
parsedURL = new URL(input, baseUrl)
|
|
136
|
-
} catch (err) {
|
|
137
|
-
throw new TypeError('Failed to parse URL from ' + input, { cause: err })
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 3. If parsedURL includes credentials, then throw a TypeError.
|
|
141
|
-
if (parsedURL.username || parsedURL.password) {
|
|
142
|
-
throw new TypeError(
|
|
143
|
-
'Request cannot be constructed from a URL that includes credentials: ' +
|
|
144
|
-
input
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 4. Set request to a new request whose URL is parsedURL.
|
|
149
|
-
request = makeRequest({ urlList: [parsedURL] })
|
|
150
|
-
|
|
151
|
-
// 5. Set fallbackMode to "cors".
|
|
152
|
-
fallbackMode = 'cors'
|
|
153
|
-
} else {
|
|
154
|
-
// 6. Otherwise:
|
|
155
|
-
|
|
156
|
-
// 7. Assert: input is a Request object.
|
|
157
|
-
assert(webidl.is.Request(input))
|
|
158
|
-
|
|
159
|
-
// 8. Set request to input’s request.
|
|
160
|
-
request = input.#state
|
|
161
|
-
|
|
162
|
-
// 9. Set signal to input’s signal.
|
|
163
|
-
signal = input.#signal
|
|
164
|
-
|
|
165
|
-
this.#dispatcher = init.dispatcher || input.#dispatcher
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// 7. Let origin be this’s relevant settings object’s origin.
|
|
169
|
-
const origin = environmentSettingsObject.settingsObject.origin
|
|
170
|
-
|
|
171
|
-
// 8. Let window be "client".
|
|
172
|
-
let window = 'client'
|
|
173
|
-
|
|
174
|
-
// 9. If request’s window is an environment settings object and its origin
|
|
175
|
-
// is same origin with origin, then set window to request’s window.
|
|
176
|
-
if (
|
|
177
|
-
request.window?.constructor?.name === 'EnvironmentSettingsObject' &&
|
|
178
|
-
sameOrigin(request.window, origin)
|
|
179
|
-
) {
|
|
180
|
-
window = request.window
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// 10. If init["window"] exists and is non-null, then throw a TypeError.
|
|
184
|
-
if (init.window != null) {
|
|
185
|
-
throw new TypeError(`'window' option '${window}' must be null`)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// 11. If init["window"] exists, then set window to "no-window".
|
|
189
|
-
if ('window' in init) {
|
|
190
|
-
window = 'no-window'
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// 12. Set request to a new request with the following properties:
|
|
194
|
-
request = makeRequest({
|
|
195
|
-
// URL request’s URL.
|
|
196
|
-
// undici implementation note: this is set as the first item in request's urlList in makeRequest
|
|
197
|
-
// method request’s method.
|
|
198
|
-
method: request.method,
|
|
199
|
-
// header list A copy of request’s header list.
|
|
200
|
-
// undici implementation note: headersList is cloned in makeRequest
|
|
201
|
-
headersList: request.headersList,
|
|
202
|
-
// unsafe-request flag Set.
|
|
203
|
-
unsafeRequest: request.unsafeRequest,
|
|
204
|
-
// client This’s relevant settings object.
|
|
205
|
-
client: environmentSettingsObject.settingsObject,
|
|
206
|
-
// window window.
|
|
207
|
-
window,
|
|
208
|
-
// priority request’s priority.
|
|
209
|
-
priority: request.priority,
|
|
210
|
-
// origin request’s origin. The propagation of the origin is only significant for navigation requests
|
|
211
|
-
// being handled by a service worker. In this scenario a request can have an origin that is different
|
|
212
|
-
// from the current client.
|
|
213
|
-
origin: request.origin,
|
|
214
|
-
// referrer request’s referrer.
|
|
215
|
-
referrer: request.referrer,
|
|
216
|
-
// referrer policy request’s referrer policy.
|
|
217
|
-
referrerPolicy: request.referrerPolicy,
|
|
218
|
-
// mode request’s mode.
|
|
219
|
-
mode: request.mode,
|
|
220
|
-
// credentials mode request’s credentials mode.
|
|
221
|
-
credentials: request.credentials,
|
|
222
|
-
// cache mode request’s cache mode.
|
|
223
|
-
cache: request.cache,
|
|
224
|
-
// redirect mode request’s redirect mode.
|
|
225
|
-
redirect: request.redirect,
|
|
226
|
-
// integrity metadata request’s integrity metadata.
|
|
227
|
-
integrity: request.integrity,
|
|
228
|
-
// keepalive request’s keepalive.
|
|
229
|
-
keepalive: request.keepalive,
|
|
230
|
-
// reload-navigation flag request’s reload-navigation flag.
|
|
231
|
-
reloadNavigation: request.reloadNavigation,
|
|
232
|
-
// history-navigation flag request’s history-navigation flag.
|
|
233
|
-
historyNavigation: request.historyNavigation,
|
|
234
|
-
// URL list A clone of request’s URL list.
|
|
235
|
-
urlList: [...request.urlList]
|
|
236
|
-
})
|
|
237
|
-
|
|
238
|
-
const initHasKey = Object.keys(init).length !== 0
|
|
239
|
-
|
|
240
|
-
// 13. If init is not empty, then:
|
|
241
|
-
if (initHasKey) {
|
|
242
|
-
// 1. If request’s mode is "navigate", then set it to "same-origin".
|
|
243
|
-
if (request.mode === 'navigate') {
|
|
244
|
-
request.mode = 'same-origin'
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// 2. Unset request’s reload-navigation flag.
|
|
248
|
-
request.reloadNavigation = false
|
|
249
|
-
|
|
250
|
-
// 3. Unset request’s history-navigation flag.
|
|
251
|
-
request.historyNavigation = false
|
|
252
|
-
|
|
253
|
-
// 4. Set request’s origin to "client".
|
|
254
|
-
request.origin = 'client'
|
|
255
|
-
|
|
256
|
-
// 5. Set request’s referrer to "client"
|
|
257
|
-
request.referrer = 'client'
|
|
258
|
-
|
|
259
|
-
// 6. Set request’s referrer policy to the empty string.
|
|
260
|
-
request.referrerPolicy = ''
|
|
261
|
-
|
|
262
|
-
// 7. Set request’s URL to request’s current URL.
|
|
263
|
-
request.url = request.urlList[request.urlList.length - 1]
|
|
264
|
-
|
|
265
|
-
// 8. Set request’s URL list to « request’s URL ».
|
|
266
|
-
request.urlList = [request.url]
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// 14. If init["referrer"] exists, then:
|
|
270
|
-
if (init.referrer !== undefined) {
|
|
271
|
-
// 1. Let referrer be init["referrer"].
|
|
272
|
-
const referrer = init.referrer
|
|
273
|
-
|
|
274
|
-
// 2. If referrer is the empty string, then set request’s referrer to "no-referrer".
|
|
275
|
-
if (referrer === '') {
|
|
276
|
-
request.referrer = 'no-referrer'
|
|
277
|
-
} else {
|
|
278
|
-
// 1. Let parsedReferrer be the result of parsing referrer with
|
|
279
|
-
// baseURL.
|
|
280
|
-
// 2. If parsedReferrer is failure, then throw a TypeError.
|
|
281
|
-
let parsedReferrer
|
|
282
|
-
try {
|
|
283
|
-
parsedReferrer = new URL(referrer, baseUrl)
|
|
284
|
-
} catch (err) {
|
|
285
|
-
throw new TypeError(`Referrer "${referrer}" is not a valid URL.`, { cause: err })
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// 3. If one of the following is true
|
|
289
|
-
// - parsedReferrer’s scheme is "about" and path is the string "client"
|
|
290
|
-
// - parsedReferrer’s origin is not same origin with origin
|
|
291
|
-
// then set request’s referrer to "client".
|
|
292
|
-
if (
|
|
293
|
-
(parsedReferrer.protocol === 'about:' && parsedReferrer.hostname === 'client') ||
|
|
294
|
-
(origin && !sameOrigin(parsedReferrer, environmentSettingsObject.settingsObject.baseUrl))
|
|
295
|
-
) {
|
|
296
|
-
request.referrer = 'client'
|
|
297
|
-
} else {
|
|
298
|
-
// 4. Otherwise, set request’s referrer to parsedReferrer.
|
|
299
|
-
request.referrer = parsedReferrer
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// 15. If init["referrerPolicy"] exists, then set request’s referrer policy
|
|
305
|
-
// to it.
|
|
306
|
-
if (init.referrerPolicy !== undefined) {
|
|
307
|
-
request.referrerPolicy = init.referrerPolicy
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// 16. Let mode be init["mode"] if it exists, and fallbackMode otherwise.
|
|
311
|
-
let mode
|
|
312
|
-
if (init.mode !== undefined) {
|
|
313
|
-
mode = init.mode
|
|
314
|
-
} else {
|
|
315
|
-
mode = fallbackMode
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// 17. If mode is "navigate", then throw a TypeError.
|
|
319
|
-
if (mode === 'navigate') {
|
|
320
|
-
throw webidl.errors.exception({
|
|
321
|
-
header: 'Request constructor',
|
|
322
|
-
message: 'invalid request mode navigate.'
|
|
323
|
-
})
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// 18. If mode is non-null, set request’s mode to mode.
|
|
327
|
-
if (mode != null) {
|
|
328
|
-
request.mode = mode
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// 19. If init["credentials"] exists, then set request’s credentials mode
|
|
332
|
-
// to it.
|
|
333
|
-
if (init.credentials !== undefined) {
|
|
334
|
-
request.credentials = init.credentials
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// 18. If init["cache"] exists, then set request’s cache mode to it.
|
|
338
|
-
if (init.cache !== undefined) {
|
|
339
|
-
request.cache = init.cache
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// 21. If request’s cache mode is "only-if-cached" and request’s mode is
|
|
343
|
-
// not "same-origin", then throw a TypeError.
|
|
344
|
-
if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
|
|
345
|
-
throw new TypeError(
|
|
346
|
-
"'only-if-cached' can be set only with 'same-origin' mode"
|
|
347
|
-
)
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// 22. If init["redirect"] exists, then set request’s redirect mode to it.
|
|
351
|
-
if (init.redirect !== undefined) {
|
|
352
|
-
request.redirect = init.redirect
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// 23. If init["integrity"] exists, then set request’s integrity metadata to it.
|
|
356
|
-
if (init.integrity != null) {
|
|
357
|
-
request.integrity = String(init.integrity)
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// 24. If init["keepalive"] exists, then set request’s keepalive to it.
|
|
361
|
-
if (init.keepalive !== undefined) {
|
|
362
|
-
request.keepalive = Boolean(init.keepalive)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// 25. If init["method"] exists, then:
|
|
366
|
-
if (init.method !== undefined) {
|
|
367
|
-
// 1. Let method be init["method"].
|
|
368
|
-
let method = init.method
|
|
369
|
-
|
|
370
|
-
const mayBeNormalized = normalizedMethodRecords[method]
|
|
371
|
-
|
|
372
|
-
if (mayBeNormalized !== undefined) {
|
|
373
|
-
// Note: Bypass validation DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH and these lowercase ones
|
|
374
|
-
request.method = mayBeNormalized
|
|
375
|
-
} else {
|
|
376
|
-
// 2. If method is not a method or method is a forbidden method, then
|
|
377
|
-
// throw a TypeError.
|
|
378
|
-
if (!isValidHTTPToken(method)) {
|
|
379
|
-
throw new TypeError(`'${method}' is not a valid HTTP method.`)
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const upperCase = method.toUpperCase()
|
|
383
|
-
|
|
384
|
-
if (forbiddenMethodsSet.has(upperCase)) {
|
|
385
|
-
throw new TypeError(`'${method}' HTTP method is unsupported.`)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// 3. Normalize method.
|
|
389
|
-
// https://fetch.spec.whatwg.org/#concept-method-normalize
|
|
390
|
-
// Note: must be in uppercase
|
|
391
|
-
method = normalizedMethodRecordsBase[upperCase] ?? method
|
|
392
|
-
|
|
393
|
-
// 4. Set request’s method to method.
|
|
394
|
-
request.method = method
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (!patchMethodWarning && request.method === 'patch') {
|
|
398
|
-
process.emitWarning('Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.', {
|
|
399
|
-
code: 'UNDICI-FETCH-patch'
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
patchMethodWarning = true
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// 26. If init["signal"] exists, then set signal to it.
|
|
407
|
-
if (init.signal !== undefined) {
|
|
408
|
-
signal = init.signal
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// 27. Set this’s request to request.
|
|
412
|
-
this.#state = request
|
|
413
|
-
|
|
414
|
-
// 28. Set this’s signal to a new AbortSignal object with this’s relevant
|
|
415
|
-
// Realm.
|
|
416
|
-
// TODO: could this be simplified with AbortSignal.any
|
|
417
|
-
// (https://dom.spec.whatwg.org/#dom-abortsignal-any)
|
|
418
|
-
const ac = new AbortController()
|
|
419
|
-
this.#signal = ac.signal
|
|
420
|
-
|
|
421
|
-
// 29. If signal is not null, then make this’s signal follow signal.
|
|
422
|
-
if (signal != null) {
|
|
423
|
-
if (signal.aborted) {
|
|
424
|
-
ac.abort(signal.reason)
|
|
425
|
-
} else {
|
|
426
|
-
// Keep a strong ref to ac while request object
|
|
427
|
-
// is alive. This is needed to prevent AbortController
|
|
428
|
-
// from being prematurely garbage collected.
|
|
429
|
-
// See, https://github.com/nodejs/undici/issues/1926.
|
|
430
|
-
this[kAbortController] = ac
|
|
431
|
-
|
|
432
|
-
const acRef = new WeakRef(ac)
|
|
433
|
-
const abort = buildAbort(acRef)
|
|
434
|
-
|
|
435
|
-
// If the max amount of listeners is equal to the default, increase it
|
|
436
|
-
if (abortSignalHasEventHandlerLeakWarning && getMaxListeners(signal) === defaultMaxListeners) {
|
|
437
|
-
setMaxListeners(1500, signal)
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
util.addAbortListener(signal, abort)
|
|
441
|
-
// The third argument must be a registry key to be unregistered.
|
|
442
|
-
// Without it, you cannot unregister.
|
|
443
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
|
|
444
|
-
// abort is used as the unregister key. (because it is unique)
|
|
445
|
-
requestFinalizer.register(ac, { signal, abort }, abort)
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// 30. Set this’s headers to a new Headers object with this’s relevant
|
|
450
|
-
// Realm, whose header list is request’s header list and guard is
|
|
451
|
-
// "request".
|
|
452
|
-
this.#headers = new Headers(kConstruct)
|
|
453
|
-
setHeadersList(this.#headers, request.headersList)
|
|
454
|
-
setHeadersGuard(this.#headers, 'request')
|
|
455
|
-
|
|
456
|
-
// 31. If this’s request’s mode is "no-cors", then:
|
|
457
|
-
if (mode === 'no-cors') {
|
|
458
|
-
// 1. If this’s request’s method is not a CORS-safelisted method,
|
|
459
|
-
// then throw a TypeError.
|
|
460
|
-
if (!corsSafeListedMethodsSet.has(request.method)) {
|
|
461
|
-
throw new TypeError(
|
|
462
|
-
`'${request.method} is unsupported in no-cors mode.`
|
|
463
|
-
)
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// 2. Set this’s headers’s guard to "request-no-cors".
|
|
467
|
-
setHeadersGuard(this.#headers, 'request-no-cors')
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// 32. If init is not empty, then:
|
|
471
|
-
if (initHasKey) {
|
|
472
|
-
/** @type {HeadersList} */
|
|
473
|
-
const headersList = getHeadersList(this.#headers)
|
|
474
|
-
// 1. Let headers be a copy of this’s headers and its associated header
|
|
475
|
-
// list.
|
|
476
|
-
// 2. If init["headers"] exists, then set headers to init["headers"].
|
|
477
|
-
const headers = init.headers !== undefined ? init.headers : new HeadersList(headersList)
|
|
478
|
-
|
|
479
|
-
// 3. Empty this’s headers’s header list.
|
|
480
|
-
headersList.clear()
|
|
481
|
-
|
|
482
|
-
// 4. If headers is a Headers object, then for each header in its header
|
|
483
|
-
// list, append header’s name/header’s value to this’s headers.
|
|
484
|
-
if (headers instanceof HeadersList) {
|
|
485
|
-
for (const { name, value } of headers.rawValues()) {
|
|
486
|
-
headersList.append(name, value, false)
|
|
487
|
-
}
|
|
488
|
-
// Note: Copy the `set-cookie` meta-data.
|
|
489
|
-
headersList.cookies = headers.cookies
|
|
490
|
-
} else {
|
|
491
|
-
// 5. Otherwise, fill this’s headers with headers.
|
|
492
|
-
fillHeaders(this.#headers, headers)
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// 33. Let inputBody be input’s request’s body if input is a Request
|
|
497
|
-
// object; otherwise null.
|
|
498
|
-
const inputBody = webidl.is.Request(input) ? input.#state.body : null
|
|
499
|
-
|
|
500
|
-
// 34. If either init["body"] exists and is non-null or inputBody is
|
|
501
|
-
// non-null, and request’s method is `GET` or `HEAD`, then throw a
|
|
502
|
-
// TypeError.
|
|
503
|
-
if (
|
|
504
|
-
(init.body != null || inputBody != null) &&
|
|
505
|
-
(request.method === 'GET' || request.method === 'HEAD')
|
|
506
|
-
) {
|
|
507
|
-
throw new TypeError('Request with GET/HEAD method cannot have body.')
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// 35. Let initBody be null.
|
|
511
|
-
let initBody = null
|
|
512
|
-
|
|
513
|
-
// 36. If init["body"] exists and is non-null, then:
|
|
514
|
-
if (init.body != null) {
|
|
515
|
-
// 1. Let Content-Type be null.
|
|
516
|
-
// 2. Set initBody and Content-Type to the result of extracting
|
|
517
|
-
// init["body"], with keepalive set to request’s keepalive.
|
|
518
|
-
const [extractedBody, contentType] = extractBody(
|
|
519
|
-
init.body,
|
|
520
|
-
request.keepalive
|
|
521
|
-
)
|
|
522
|
-
initBody = extractedBody
|
|
523
|
-
|
|
524
|
-
// 3, If Content-Type is non-null and this’s headers’s header list does
|
|
525
|
-
// not contain `Content-Type`, then append `Content-Type`/Content-Type to
|
|
526
|
-
// this’s headers.
|
|
527
|
-
if (contentType && !getHeadersList(this.#headers).contains('content-type', true)) {
|
|
528
|
-
this.#headers.append('content-type', contentType, true)
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// 37. Let inputOrInitBody be initBody if it is non-null; otherwise
|
|
533
|
-
// inputBody.
|
|
534
|
-
const inputOrInitBody = initBody ?? inputBody
|
|
535
|
-
|
|
536
|
-
// 38. If inputOrInitBody is non-null and inputOrInitBody’s source is
|
|
537
|
-
// null, then:
|
|
538
|
-
if (inputOrInitBody != null && inputOrInitBody.source == null) {
|
|
539
|
-
// 1. If initBody is non-null and init["duplex"] does not exist,
|
|
540
|
-
// then throw a TypeError.
|
|
541
|
-
if (initBody != null && init.duplex == null) {
|
|
542
|
-
throw new TypeError('RequestInit: duplex option is required when sending a body.')
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// 2. If this’s request’s mode is neither "same-origin" nor "cors",
|
|
546
|
-
// then throw a TypeError.
|
|
547
|
-
if (request.mode !== 'same-origin' && request.mode !== 'cors') {
|
|
548
|
-
throw new TypeError(
|
|
549
|
-
'If request is made from ReadableStream, mode should be "same-origin" or "cors"'
|
|
550
|
-
)
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// 3. Set this’s request’s use-CORS-preflight flag.
|
|
554
|
-
request.useCORSPreflightFlag = true
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// 39. Let finalBody be inputOrInitBody.
|
|
558
|
-
let finalBody = inputOrInitBody
|
|
559
|
-
|
|
560
|
-
// 40. If initBody is null and inputBody is non-null, then:
|
|
561
|
-
if (initBody == null && inputBody != null) {
|
|
562
|
-
// 1. If input is unusable, then throw a TypeError.
|
|
563
|
-
if (bodyUnusable(input.#state)) {
|
|
564
|
-
throw new TypeError(
|
|
565
|
-
'Cannot construct a Request with a Request object that has already been used.'
|
|
566
|
-
)
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// 2. Set finalBody to the result of creating a proxy for inputBody.
|
|
570
|
-
// https://streams.spec.whatwg.org/#readablestream-create-a-proxy
|
|
571
|
-
const identityTransform = new TransformStream()
|
|
572
|
-
inputBody.stream.pipeThrough(identityTransform)
|
|
573
|
-
finalBody = {
|
|
574
|
-
source: inputBody.source,
|
|
575
|
-
length: inputBody.length,
|
|
576
|
-
stream: identityTransform.readable
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// 41. Set this’s request’s body to finalBody.
|
|
581
|
-
this.#state.body = finalBody
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// Returns request’s HTTP method, which is "GET" by default.
|
|
585
|
-
get method () {
|
|
586
|
-
webidl.brandCheck(this, Request)
|
|
587
|
-
|
|
588
|
-
// The method getter steps are to return this’s request’s method.
|
|
589
|
-
return this.#state.method
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// Returns the URL of request as a string.
|
|
593
|
-
get url () {
|
|
594
|
-
webidl.brandCheck(this, Request)
|
|
595
|
-
|
|
596
|
-
// The url getter steps are to return this’s request’s URL, serialized.
|
|
597
|
-
return URLSerializer(this.#state.url)
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// Returns a Headers object consisting of the headers associated with request.
|
|
601
|
-
// Note that headers added in the network layer by the user agent will not
|
|
602
|
-
// be accounted for in this object, e.g., the "Host" header.
|
|
603
|
-
get headers () {
|
|
604
|
-
webidl.brandCheck(this, Request)
|
|
605
|
-
|
|
606
|
-
// The headers getter steps are to return this’s headers.
|
|
607
|
-
return this.#headers
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// Returns the kind of resource requested by request, e.g., "document"
|
|
611
|
-
// or "script".
|
|
612
|
-
get destination () {
|
|
613
|
-
webidl.brandCheck(this, Request)
|
|
614
|
-
|
|
615
|
-
// The destination getter are to return this’s request’s destination.
|
|
616
|
-
return this.#state.destination
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// Returns the referrer of request. Its value can be a same-origin URL if
|
|
620
|
-
// explicitly set in init, the empty string to indicate no referrer, and
|
|
621
|
-
// "about:client" when defaulting to the global’s default. This is used
|
|
622
|
-
// during fetching to determine the value of the `Referer` header of the
|
|
623
|
-
// request being made.
|
|
624
|
-
get referrer () {
|
|
625
|
-
webidl.brandCheck(this, Request)
|
|
626
|
-
|
|
627
|
-
// 1. If this’s request’s referrer is "no-referrer", then return the
|
|
628
|
-
// empty string.
|
|
629
|
-
if (this.#state.referrer === 'no-referrer') {
|
|
630
|
-
return ''
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// 2. If this’s request’s referrer is "client", then return
|
|
634
|
-
// "about:client".
|
|
635
|
-
if (this.#state.referrer === 'client') {
|
|
636
|
-
return 'about:client'
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// Return this’s request’s referrer, serialized.
|
|
640
|
-
return this.#state.referrer.toString()
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// Returns the referrer policy associated with request.
|
|
644
|
-
// This is used during fetching to compute the value of the request’s
|
|
645
|
-
// referrer.
|
|
646
|
-
get referrerPolicy () {
|
|
647
|
-
webidl.brandCheck(this, Request)
|
|
648
|
-
|
|
649
|
-
// The referrerPolicy getter steps are to return this’s request’s referrer policy.
|
|
650
|
-
return this.#state.referrerPolicy
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
// Returns the mode associated with request, which is a string indicating
|
|
654
|
-
// whether the request will use CORS, or will be restricted to same-origin
|
|
655
|
-
// URLs.
|
|
656
|
-
get mode () {
|
|
657
|
-
webidl.brandCheck(this, Request)
|
|
658
|
-
|
|
659
|
-
// The mode getter steps are to return this’s request’s mode.
|
|
660
|
-
return this.#state.mode
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// Returns the credentials mode associated with request,
|
|
664
|
-
// which is a string indicating whether credentials will be sent with the
|
|
665
|
-
// request always, never, or only when sent to a same-origin URL.
|
|
666
|
-
get credentials () {
|
|
667
|
-
webidl.brandCheck(this, Request)
|
|
668
|
-
|
|
669
|
-
// The credentials getter steps are to return this’s request’s credentials mode.
|
|
670
|
-
return this.#state.credentials
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// Returns the cache mode associated with request,
|
|
674
|
-
// which is a string indicating how the request will
|
|
675
|
-
// interact with the browser’s cache when fetching.
|
|
676
|
-
get cache () {
|
|
677
|
-
webidl.brandCheck(this, Request)
|
|
678
|
-
|
|
679
|
-
// The cache getter steps are to return this’s request’s cache mode.
|
|
680
|
-
return this.#state.cache
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
// Returns the redirect mode associated with request,
|
|
684
|
-
// which is a string indicating how redirects for the
|
|
685
|
-
// request will be handled during fetching. A request
|
|
686
|
-
// will follow redirects by default.
|
|
687
|
-
get redirect () {
|
|
688
|
-
webidl.brandCheck(this, Request)
|
|
689
|
-
|
|
690
|
-
// The redirect getter steps are to return this’s request’s redirect mode.
|
|
691
|
-
return this.#state.redirect
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
// Returns request’s subresource integrity metadata, which is a
|
|
695
|
-
// cryptographic hash of the resource being fetched. Its value
|
|
696
|
-
// consists of multiple hashes separated by whitespace. [SRI]
|
|
697
|
-
get integrity () {
|
|
698
|
-
webidl.brandCheck(this, Request)
|
|
699
|
-
|
|
700
|
-
// The integrity getter steps are to return this’s request’s integrity
|
|
701
|
-
// metadata.
|
|
702
|
-
return this.#state.integrity
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
// Returns a boolean indicating whether or not request can outlive the
|
|
706
|
-
// global in which it was created.
|
|
707
|
-
get keepalive () {
|
|
708
|
-
webidl.brandCheck(this, Request)
|
|
709
|
-
|
|
710
|
-
// The keepalive getter steps are to return this’s request’s keepalive.
|
|
711
|
-
return this.#state.keepalive
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// Returns a boolean indicating whether or not request is for a reload
|
|
715
|
-
// navigation.
|
|
716
|
-
get isReloadNavigation () {
|
|
717
|
-
webidl.brandCheck(this, Request)
|
|
718
|
-
|
|
719
|
-
// The isReloadNavigation getter steps are to return true if this’s
|
|
720
|
-
// request’s reload-navigation flag is set; otherwise false.
|
|
721
|
-
return this.#state.reloadNavigation
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// Returns a boolean indicating whether or not request is for a history
|
|
725
|
-
// navigation (a.k.a. back-forward navigation).
|
|
726
|
-
get isHistoryNavigation () {
|
|
727
|
-
webidl.brandCheck(this, Request)
|
|
728
|
-
|
|
729
|
-
// The isHistoryNavigation getter steps are to return true if this’s request’s
|
|
730
|
-
// history-navigation flag is set; otherwise false.
|
|
731
|
-
return this.#state.historyNavigation
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// Returns the signal associated with request, which is an AbortSignal
|
|
735
|
-
// object indicating whether or not request has been aborted, and its
|
|
736
|
-
// abort event handler.
|
|
737
|
-
get signal () {
|
|
738
|
-
webidl.brandCheck(this, Request)
|
|
739
|
-
|
|
740
|
-
// The signal getter steps are to return this’s signal.
|
|
741
|
-
return this.#signal
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
get body () {
|
|
745
|
-
webidl.brandCheck(this, Request)
|
|
746
|
-
|
|
747
|
-
return this.#state.body ? this.#state.body.stream : null
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
get bodyUsed () {
|
|
751
|
-
webidl.brandCheck(this, Request)
|
|
752
|
-
|
|
753
|
-
return !!this.#state.body && util.isDisturbed(this.#state.body.stream)
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
get duplex () {
|
|
757
|
-
webidl.brandCheck(this, Request)
|
|
758
|
-
|
|
759
|
-
return 'half'
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// Returns a clone of request.
|
|
763
|
-
clone () {
|
|
764
|
-
webidl.brandCheck(this, Request)
|
|
765
|
-
|
|
766
|
-
// 1. If this is unusable, then throw a TypeError.
|
|
767
|
-
if (bodyUnusable(this.#state)) {
|
|
768
|
-
throw new TypeError('unusable')
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
// 2. Let clonedRequest be the result of cloning this’s request.
|
|
772
|
-
const clonedRequest = cloneRequest(this.#state)
|
|
773
|
-
|
|
774
|
-
// 3. Let clonedRequestObject be the result of creating a Request object,
|
|
775
|
-
// given clonedRequest, this’s headers’s guard, and this’s relevant Realm.
|
|
776
|
-
// 4. Make clonedRequestObject’s signal follow this’s signal.
|
|
777
|
-
const ac = new AbortController()
|
|
778
|
-
if (this.signal.aborted) {
|
|
779
|
-
ac.abort(this.signal.reason)
|
|
780
|
-
} else {
|
|
781
|
-
let list = dependentControllerMap.get(this.signal)
|
|
782
|
-
if (list === undefined) {
|
|
783
|
-
list = new Set()
|
|
784
|
-
dependentControllerMap.set(this.signal, list)
|
|
785
|
-
}
|
|
786
|
-
const acRef = new WeakRef(ac)
|
|
787
|
-
list.add(acRef)
|
|
788
|
-
util.addAbortListener(
|
|
789
|
-
ac.signal,
|
|
790
|
-
buildAbort(acRef)
|
|
791
|
-
)
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
// 4. Return clonedRequestObject.
|
|
795
|
-
return fromInnerRequest(clonedRequest, this.#dispatcher, ac.signal, getHeadersGuard(this.#headers))
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
[nodeUtil.inspect.custom] (depth, options) {
|
|
799
|
-
if (options.depth === null) {
|
|
800
|
-
options.depth = 2
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
options.colors ??= true
|
|
804
|
-
|
|
805
|
-
const properties = {
|
|
806
|
-
method: this.method,
|
|
807
|
-
url: this.url,
|
|
808
|
-
headers: this.headers,
|
|
809
|
-
destination: this.destination,
|
|
810
|
-
referrer: this.referrer,
|
|
811
|
-
referrerPolicy: this.referrerPolicy,
|
|
812
|
-
mode: this.mode,
|
|
813
|
-
credentials: this.credentials,
|
|
814
|
-
cache: this.cache,
|
|
815
|
-
redirect: this.redirect,
|
|
816
|
-
integrity: this.integrity,
|
|
817
|
-
keepalive: this.keepalive,
|
|
818
|
-
isReloadNavigation: this.isReloadNavigation,
|
|
819
|
-
isHistoryNavigation: this.isHistoryNavigation,
|
|
820
|
-
signal: this.signal
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
return `Request ${nodeUtil.formatWithOptions(options, properties)}`
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
/**
|
|
827
|
-
* @param {Request} request
|
|
828
|
-
* @param {AbortSignal} newSignal
|
|
829
|
-
*/
|
|
830
|
-
static setRequestSignal (request, newSignal) {
|
|
831
|
-
request.#signal = newSignal
|
|
832
|
-
return request
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* @param {Request} request
|
|
837
|
-
*/
|
|
838
|
-
static getRequestDispatcher (request) {
|
|
839
|
-
return request.#dispatcher
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* @param {Request} request
|
|
844
|
-
* @param {import('../../dispatcher/dispatcher')} newDispatcher
|
|
845
|
-
*/
|
|
846
|
-
static setRequestDispatcher (request, newDispatcher) {
|
|
847
|
-
request.#dispatcher = newDispatcher
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* @param {Request} request
|
|
852
|
-
* @param {Headers} newHeaders
|
|
853
|
-
*/
|
|
854
|
-
static setRequestHeaders (request, newHeaders) {
|
|
855
|
-
request.#headers = newHeaders
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
/**
|
|
859
|
-
* @param {Request} request
|
|
860
|
-
*/
|
|
861
|
-
static getRequestState (request) {
|
|
862
|
-
return request.#state
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* @param {Request} request
|
|
867
|
-
* @param {any} newState
|
|
868
|
-
*/
|
|
869
|
-
static setRequestState (request, newState) {
|
|
870
|
-
request.#state = newState
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
const { setRequestSignal, getRequestDispatcher, setRequestDispatcher, setRequestHeaders, getRequestState, setRequestState } = Request
|
|
875
|
-
Reflect.deleteProperty(Request, 'setRequestSignal')
|
|
876
|
-
Reflect.deleteProperty(Request, 'getRequestDispatcher')
|
|
877
|
-
Reflect.deleteProperty(Request, 'setRequestDispatcher')
|
|
878
|
-
Reflect.deleteProperty(Request, 'setRequestHeaders')
|
|
879
|
-
Reflect.deleteProperty(Request, 'getRequestState')
|
|
880
|
-
Reflect.deleteProperty(Request, 'setRequestState')
|
|
881
|
-
|
|
882
|
-
mixinBody(Request, getRequestState)
|
|
883
|
-
|
|
884
|
-
// https://fetch.spec.whatwg.org/#requests
|
|
885
|
-
function makeRequest (init) {
|
|
886
|
-
return {
|
|
887
|
-
method: init.method ?? 'GET',
|
|
888
|
-
localURLsOnly: init.localURLsOnly ?? false,
|
|
889
|
-
unsafeRequest: init.unsafeRequest ?? false,
|
|
890
|
-
body: init.body ?? null,
|
|
891
|
-
client: init.client ?? null,
|
|
892
|
-
reservedClient: init.reservedClient ?? null,
|
|
893
|
-
replacesClientId: init.replacesClientId ?? '',
|
|
894
|
-
window: init.window ?? 'client',
|
|
895
|
-
keepalive: init.keepalive ?? false,
|
|
896
|
-
serviceWorkers: init.serviceWorkers ?? 'all',
|
|
897
|
-
initiator: init.initiator ?? '',
|
|
898
|
-
destination: init.destination ?? '',
|
|
899
|
-
priority: init.priority ?? null,
|
|
900
|
-
origin: init.origin ?? 'client',
|
|
901
|
-
policyContainer: init.policyContainer ?? 'client',
|
|
902
|
-
referrer: init.referrer ?? 'client',
|
|
903
|
-
referrerPolicy: init.referrerPolicy ?? '',
|
|
904
|
-
mode: init.mode ?? 'no-cors',
|
|
905
|
-
useCORSPreflightFlag: init.useCORSPreflightFlag ?? false,
|
|
906
|
-
credentials: init.credentials ?? 'same-origin',
|
|
907
|
-
useCredentials: init.useCredentials ?? false,
|
|
908
|
-
cache: init.cache ?? 'default',
|
|
909
|
-
redirect: init.redirect ?? 'follow',
|
|
910
|
-
integrity: init.integrity ?? '',
|
|
911
|
-
cryptoGraphicsNonceMetadata: init.cryptoGraphicsNonceMetadata ?? '',
|
|
912
|
-
parserMetadata: init.parserMetadata ?? '',
|
|
913
|
-
reloadNavigation: init.reloadNavigation ?? false,
|
|
914
|
-
historyNavigation: init.historyNavigation ?? false,
|
|
915
|
-
userActivation: init.userActivation ?? false,
|
|
916
|
-
taintedOrigin: init.taintedOrigin ?? false,
|
|
917
|
-
redirectCount: init.redirectCount ?? 0,
|
|
918
|
-
responseTainting: init.responseTainting ?? 'basic',
|
|
919
|
-
preventNoCacheCacheControlHeaderModification: init.preventNoCacheCacheControlHeaderModification ?? false,
|
|
920
|
-
done: init.done ?? false,
|
|
921
|
-
timingAllowFailed: init.timingAllowFailed ?? false,
|
|
922
|
-
urlList: init.urlList,
|
|
923
|
-
url: init.urlList[0],
|
|
924
|
-
headersList: init.headersList
|
|
925
|
-
? new HeadersList(init.headersList)
|
|
926
|
-
: new HeadersList()
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
// https://fetch.spec.whatwg.org/#concept-request-clone
|
|
931
|
-
function cloneRequest (request) {
|
|
932
|
-
// To clone a request request, run these steps:
|
|
933
|
-
|
|
934
|
-
// 1. Let newRequest be a copy of request, except for its body.
|
|
935
|
-
const newRequest = makeRequest({ ...request, body: null })
|
|
936
|
-
|
|
937
|
-
// 2. If request’s body is non-null, set newRequest’s body to the
|
|
938
|
-
// result of cloning request’s body.
|
|
939
|
-
if (request.body != null) {
|
|
940
|
-
newRequest.body = cloneBody(newRequest, request.body)
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// 3. Return newRequest.
|
|
944
|
-
return newRequest
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
/**
|
|
948
|
-
* @see https://fetch.spec.whatwg.org/#request-create
|
|
949
|
-
* @param {any} innerRequest
|
|
950
|
-
* @param {import('../../dispatcher/agent')} dispatcher
|
|
951
|
-
* @param {AbortSignal} signal
|
|
952
|
-
* @param {'request' | 'immutable' | 'request-no-cors' | 'response' | 'none'} guard
|
|
953
|
-
* @returns {Request}
|
|
954
|
-
*/
|
|
955
|
-
function fromInnerRequest (innerRequest, dispatcher, signal, guard) {
|
|
956
|
-
const request = new Request(kConstruct)
|
|
957
|
-
setRequestState(request, innerRequest)
|
|
958
|
-
setRequestDispatcher(request, dispatcher)
|
|
959
|
-
setRequestSignal(request, signal)
|
|
960
|
-
const headers = new Headers(kConstruct)
|
|
961
|
-
setRequestHeaders(request, headers)
|
|
962
|
-
setHeadersList(headers, innerRequest.headersList)
|
|
963
|
-
setHeadersGuard(headers, guard)
|
|
964
|
-
return request
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
Object.defineProperties(Request.prototype, {
|
|
968
|
-
method: kEnumerableProperty,
|
|
969
|
-
url: kEnumerableProperty,
|
|
970
|
-
headers: kEnumerableProperty,
|
|
971
|
-
redirect: kEnumerableProperty,
|
|
972
|
-
clone: kEnumerableProperty,
|
|
973
|
-
signal: kEnumerableProperty,
|
|
974
|
-
duplex: kEnumerableProperty,
|
|
975
|
-
destination: kEnumerableProperty,
|
|
976
|
-
body: kEnumerableProperty,
|
|
977
|
-
bodyUsed: kEnumerableProperty,
|
|
978
|
-
isHistoryNavigation: kEnumerableProperty,
|
|
979
|
-
isReloadNavigation: kEnumerableProperty,
|
|
980
|
-
keepalive: kEnumerableProperty,
|
|
981
|
-
integrity: kEnumerableProperty,
|
|
982
|
-
cache: kEnumerableProperty,
|
|
983
|
-
credentials: kEnumerableProperty,
|
|
984
|
-
attribute: kEnumerableProperty,
|
|
985
|
-
referrerPolicy: kEnumerableProperty,
|
|
986
|
-
referrer: kEnumerableProperty,
|
|
987
|
-
mode: kEnumerableProperty,
|
|
988
|
-
[Symbol.toStringTag]: {
|
|
989
|
-
value: 'Request',
|
|
990
|
-
configurable: true
|
|
991
|
-
}
|
|
992
|
-
})
|
|
993
|
-
|
|
994
|
-
webidl.is.Request = webidl.util.MakeTypeAssertion(Request)
|
|
995
|
-
|
|
996
|
-
// https://fetch.spec.whatwg.org/#requestinfo
|
|
997
|
-
webidl.converters.RequestInfo = function (V, prefix, argument) {
|
|
998
|
-
if (typeof V === 'string') {
|
|
999
|
-
return webidl.converters.USVString(V)
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
if (webidl.is.Request(V)) {
|
|
1003
|
-
return V
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
return webidl.converters.USVString(V)
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
// https://fetch.spec.whatwg.org/#requestinit
|
|
1010
|
-
webidl.converters.RequestInit = webidl.dictionaryConverter([
|
|
1011
|
-
{
|
|
1012
|
-
key: 'method',
|
|
1013
|
-
converter: webidl.converters.ByteString
|
|
1014
|
-
},
|
|
1015
|
-
{
|
|
1016
|
-
key: 'headers',
|
|
1017
|
-
converter: webidl.converters.HeadersInit
|
|
1018
|
-
},
|
|
1019
|
-
{
|
|
1020
|
-
key: 'body',
|
|
1021
|
-
converter: webidl.nullableConverter(
|
|
1022
|
-
webidl.converters.BodyInit
|
|
1023
|
-
)
|
|
1024
|
-
},
|
|
1025
|
-
{
|
|
1026
|
-
key: 'referrer',
|
|
1027
|
-
converter: webidl.converters.USVString
|
|
1028
|
-
},
|
|
1029
|
-
{
|
|
1030
|
-
key: 'referrerPolicy',
|
|
1031
|
-
converter: webidl.converters.DOMString,
|
|
1032
|
-
// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy
|
|
1033
|
-
allowedValues: referrerPolicy
|
|
1034
|
-
},
|
|
1035
|
-
{
|
|
1036
|
-
key: 'mode',
|
|
1037
|
-
converter: webidl.converters.DOMString,
|
|
1038
|
-
// https://fetch.spec.whatwg.org/#concept-request-mode
|
|
1039
|
-
allowedValues: requestMode
|
|
1040
|
-
},
|
|
1041
|
-
{
|
|
1042
|
-
key: 'credentials',
|
|
1043
|
-
converter: webidl.converters.DOMString,
|
|
1044
|
-
// https://fetch.spec.whatwg.org/#requestcredentials
|
|
1045
|
-
allowedValues: requestCredentials
|
|
1046
|
-
},
|
|
1047
|
-
{
|
|
1048
|
-
key: 'cache',
|
|
1049
|
-
converter: webidl.converters.DOMString,
|
|
1050
|
-
// https://fetch.spec.whatwg.org/#requestcache
|
|
1051
|
-
allowedValues: requestCache
|
|
1052
|
-
},
|
|
1053
|
-
{
|
|
1054
|
-
key: 'redirect',
|
|
1055
|
-
converter: webidl.converters.DOMString,
|
|
1056
|
-
// https://fetch.spec.whatwg.org/#requestredirect
|
|
1057
|
-
allowedValues: requestRedirect
|
|
1058
|
-
},
|
|
1059
|
-
{
|
|
1060
|
-
key: 'integrity',
|
|
1061
|
-
converter: webidl.converters.DOMString
|
|
1062
|
-
},
|
|
1063
|
-
{
|
|
1064
|
-
key: 'keepalive',
|
|
1065
|
-
converter: webidl.converters.boolean
|
|
1066
|
-
},
|
|
1067
|
-
{
|
|
1068
|
-
key: 'signal',
|
|
1069
|
-
converter: webidl.nullableConverter(
|
|
1070
|
-
(signal) => webidl.converters.AbortSignal(
|
|
1071
|
-
signal,
|
|
1072
|
-
'RequestInit',
|
|
1073
|
-
'signal'
|
|
1074
|
-
)
|
|
1075
|
-
)
|
|
1076
|
-
},
|
|
1077
|
-
{
|
|
1078
|
-
key: 'window',
|
|
1079
|
-
converter: webidl.converters.any
|
|
1080
|
-
},
|
|
1081
|
-
{
|
|
1082
|
-
key: 'duplex',
|
|
1083
|
-
converter: webidl.converters.DOMString,
|
|
1084
|
-
allowedValues: requestDuplex
|
|
1085
|
-
},
|
|
1086
|
-
{
|
|
1087
|
-
key: 'dispatcher', // undici specific option
|
|
1088
|
-
converter: webidl.converters.any
|
|
1089
|
-
}
|
|
1090
|
-
])
|
|
1091
|
-
|
|
1092
|
-
module.exports = {
|
|
1093
|
-
Request,
|
|
1094
|
-
makeRequest,
|
|
1095
|
-
fromInnerRequest,
|
|
1096
|
-
cloneRequest,
|
|
1097
|
-
getRequestDispatcher,
|
|
1098
|
-
getRequestState
|
|
1099
|
-
}
|