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,636 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { Headers, HeadersList, fill, getHeadersGuard, setHeadersGuard, setHeadersList } = require('./headers')
|
|
4
|
-
const { extractBody, cloneBody, mixinBody, hasFinalizationRegistry, streamRegistry, bodyUnusable } = require('./body')
|
|
5
|
-
const util = require('../../core/util')
|
|
6
|
-
const nodeUtil = require('node:util')
|
|
7
|
-
const { kEnumerableProperty } = util
|
|
8
|
-
const {
|
|
9
|
-
isValidReasonPhrase,
|
|
10
|
-
isCancelled,
|
|
11
|
-
isAborted,
|
|
12
|
-
serializeJavascriptValueToJSONString,
|
|
13
|
-
isErrorLike,
|
|
14
|
-
isomorphicEncode,
|
|
15
|
-
environmentSettingsObject: relevantRealm
|
|
16
|
-
} = require('./util')
|
|
17
|
-
const {
|
|
18
|
-
redirectStatusSet,
|
|
19
|
-
nullBodyStatus
|
|
20
|
-
} = require('./constants')
|
|
21
|
-
const { webidl } = require('./webidl')
|
|
22
|
-
const { URLSerializer } = require('./data-url')
|
|
23
|
-
const { kConstruct } = require('../../core/symbols')
|
|
24
|
-
const assert = require('node:assert')
|
|
25
|
-
const { types } = require('node:util')
|
|
26
|
-
|
|
27
|
-
const textEncoder = new TextEncoder('utf-8')
|
|
28
|
-
|
|
29
|
-
// https://fetch.spec.whatwg.org/#response-class
|
|
30
|
-
class Response {
|
|
31
|
-
/** @type {Headers} */
|
|
32
|
-
#headers
|
|
33
|
-
|
|
34
|
-
#state
|
|
35
|
-
|
|
36
|
-
// Creates network error Response.
|
|
37
|
-
static error () {
|
|
38
|
-
// The static error() method steps are to return the result of creating a
|
|
39
|
-
// Response object, given a new network error, "immutable", and this’s
|
|
40
|
-
// relevant Realm.
|
|
41
|
-
const responseObject = fromInnerResponse(makeNetworkError(), 'immutable')
|
|
42
|
-
|
|
43
|
-
return responseObject
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// https://fetch.spec.whatwg.org/#dom-response-json
|
|
47
|
-
static json (data, init = undefined) {
|
|
48
|
-
webidl.argumentLengthCheck(arguments, 1, 'Response.json')
|
|
49
|
-
|
|
50
|
-
if (init !== null) {
|
|
51
|
-
init = webidl.converters.ResponseInit(init)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 1. Let bytes the result of running serialize a JavaScript value to JSON bytes on data.
|
|
55
|
-
const bytes = textEncoder.encode(
|
|
56
|
-
serializeJavascriptValueToJSONString(data)
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
// 2. Let body be the result of extracting bytes.
|
|
60
|
-
const body = extractBody(bytes)
|
|
61
|
-
|
|
62
|
-
// 3. Let responseObject be the result of creating a Response object, given a new response,
|
|
63
|
-
// "response", and this’s relevant Realm.
|
|
64
|
-
const responseObject = fromInnerResponse(makeResponse({}), 'response')
|
|
65
|
-
|
|
66
|
-
// 4. Perform initialize a response given responseObject, init, and (body, "application/json").
|
|
67
|
-
initializeResponse(responseObject, init, { body: body[0], type: 'application/json' })
|
|
68
|
-
|
|
69
|
-
// 5. Return responseObject.
|
|
70
|
-
return responseObject
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Creates a redirect Response that redirects to url with status status.
|
|
74
|
-
static redirect (url, status = 302) {
|
|
75
|
-
webidl.argumentLengthCheck(arguments, 1, 'Response.redirect')
|
|
76
|
-
|
|
77
|
-
url = webidl.converters.USVString(url)
|
|
78
|
-
status = webidl.converters['unsigned short'](status)
|
|
79
|
-
|
|
80
|
-
// 1. Let parsedURL be the result of parsing url with current settings
|
|
81
|
-
// object’s API base URL.
|
|
82
|
-
// 2. If parsedURL is failure, then throw a TypeError.
|
|
83
|
-
// TODO: base-URL?
|
|
84
|
-
let parsedURL
|
|
85
|
-
try {
|
|
86
|
-
parsedURL = new URL(url, relevantRealm.settingsObject.baseUrl)
|
|
87
|
-
} catch (err) {
|
|
88
|
-
throw new TypeError(`Failed to parse URL from ${url}`, { cause: err })
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 3. If status is not a redirect status, then throw a RangeError.
|
|
92
|
-
if (!redirectStatusSet.has(status)) {
|
|
93
|
-
throw new RangeError(`Invalid status code ${status}`)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 4. Let responseObject be the result of creating a Response object,
|
|
97
|
-
// given a new response, "immutable", and this’s relevant Realm.
|
|
98
|
-
const responseObject = fromInnerResponse(makeResponse({}), 'immutable')
|
|
99
|
-
|
|
100
|
-
// 5. Set responseObject’s response’s status to status.
|
|
101
|
-
responseObject.#state.status = status
|
|
102
|
-
|
|
103
|
-
// 6. Let value be parsedURL, serialized and isomorphic encoded.
|
|
104
|
-
const value = isomorphicEncode(URLSerializer(parsedURL))
|
|
105
|
-
|
|
106
|
-
// 7. Append `Location`/value to responseObject’s response’s header list.
|
|
107
|
-
responseObject.#state.headersList.append('location', value, true)
|
|
108
|
-
|
|
109
|
-
// 8. Return responseObject.
|
|
110
|
-
return responseObject
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// https://fetch.spec.whatwg.org/#dom-response
|
|
114
|
-
constructor (body = null, init = undefined) {
|
|
115
|
-
webidl.util.markAsUncloneable(this)
|
|
116
|
-
|
|
117
|
-
if (body === kConstruct) {
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (body !== null) {
|
|
122
|
-
body = webidl.converters.BodyInit(body)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
init = webidl.converters.ResponseInit(init)
|
|
126
|
-
|
|
127
|
-
// 1. Set this’s response to a new response.
|
|
128
|
-
this.#state = makeResponse({})
|
|
129
|
-
|
|
130
|
-
// 2. Set this’s headers to a new Headers object with this’s relevant
|
|
131
|
-
// Realm, whose header list is this’s response’s header list and guard
|
|
132
|
-
// is "response".
|
|
133
|
-
this.#headers = new Headers(kConstruct)
|
|
134
|
-
setHeadersGuard(this.#headers, 'response')
|
|
135
|
-
setHeadersList(this.#headers, this.#state.headersList)
|
|
136
|
-
|
|
137
|
-
// 3. Let bodyWithType be null.
|
|
138
|
-
let bodyWithType = null
|
|
139
|
-
|
|
140
|
-
// 4. If body is non-null, then set bodyWithType to the result of extracting body.
|
|
141
|
-
if (body != null) {
|
|
142
|
-
const [extractedBody, type] = extractBody(body)
|
|
143
|
-
bodyWithType = { body: extractedBody, type }
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// 5. Perform initialize a response given this, init, and bodyWithType.
|
|
147
|
-
initializeResponse(this, init, bodyWithType)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Returns response’s type, e.g., "cors".
|
|
151
|
-
get type () {
|
|
152
|
-
webidl.brandCheck(this, Response)
|
|
153
|
-
|
|
154
|
-
// The type getter steps are to return this’s response’s type.
|
|
155
|
-
return this.#state.type
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Returns response’s URL, if it has one; otherwise the empty string.
|
|
159
|
-
get url () {
|
|
160
|
-
webidl.brandCheck(this, Response)
|
|
161
|
-
|
|
162
|
-
const urlList = this.#state.urlList
|
|
163
|
-
|
|
164
|
-
// The url getter steps are to return the empty string if this’s
|
|
165
|
-
// response’s URL is null; otherwise this’s response’s URL,
|
|
166
|
-
// serialized with exclude fragment set to true.
|
|
167
|
-
const url = urlList[urlList.length - 1] ?? null
|
|
168
|
-
|
|
169
|
-
if (url === null) {
|
|
170
|
-
return ''
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return URLSerializer(url, true)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Returns whether response was obtained through a redirect.
|
|
177
|
-
get redirected () {
|
|
178
|
-
webidl.brandCheck(this, Response)
|
|
179
|
-
|
|
180
|
-
// The redirected getter steps are to return true if this’s response’s URL
|
|
181
|
-
// list has more than one item; otherwise false.
|
|
182
|
-
return this.#state.urlList.length > 1
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Returns response’s status.
|
|
186
|
-
get status () {
|
|
187
|
-
webidl.brandCheck(this, Response)
|
|
188
|
-
|
|
189
|
-
// The status getter steps are to return this’s response’s status.
|
|
190
|
-
return this.#state.status
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Returns whether response’s status is an ok status.
|
|
194
|
-
get ok () {
|
|
195
|
-
webidl.brandCheck(this, Response)
|
|
196
|
-
|
|
197
|
-
// The ok getter steps are to return true if this’s response’s status is an
|
|
198
|
-
// ok status; otherwise false.
|
|
199
|
-
return this.#state.status >= 200 && this.#state.status <= 299
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Returns response’s status message.
|
|
203
|
-
get statusText () {
|
|
204
|
-
webidl.brandCheck(this, Response)
|
|
205
|
-
|
|
206
|
-
// The statusText getter steps are to return this’s response’s status
|
|
207
|
-
// message.
|
|
208
|
-
return this.#state.statusText
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Returns response’s headers as Headers.
|
|
212
|
-
get headers () {
|
|
213
|
-
webidl.brandCheck(this, Response)
|
|
214
|
-
|
|
215
|
-
// The headers getter steps are to return this’s headers.
|
|
216
|
-
return this.#headers
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
get body () {
|
|
220
|
-
webidl.brandCheck(this, Response)
|
|
221
|
-
|
|
222
|
-
return this.#state.body ? this.#state.body.stream : null
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
get bodyUsed () {
|
|
226
|
-
webidl.brandCheck(this, Response)
|
|
227
|
-
|
|
228
|
-
return !!this.#state.body && util.isDisturbed(this.#state.body.stream)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Returns a clone of response.
|
|
232
|
-
clone () {
|
|
233
|
-
webidl.brandCheck(this, Response)
|
|
234
|
-
|
|
235
|
-
// 1. If this is unusable, then throw a TypeError.
|
|
236
|
-
if (bodyUnusable(this.#state)) {
|
|
237
|
-
throw webidl.errors.exception({
|
|
238
|
-
header: 'Response.clone',
|
|
239
|
-
message: 'Body has already been consumed.'
|
|
240
|
-
})
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// 2. Let clonedResponse be the result of cloning this’s response.
|
|
244
|
-
const clonedResponse = cloneResponse(this.#state)
|
|
245
|
-
|
|
246
|
-
// 3. Return the result of creating a Response object, given
|
|
247
|
-
// clonedResponse, this’s headers’s guard, and this’s relevant Realm.
|
|
248
|
-
return fromInnerResponse(clonedResponse, getHeadersGuard(this.#headers))
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
[nodeUtil.inspect.custom] (depth, options) {
|
|
252
|
-
if (options.depth === null) {
|
|
253
|
-
options.depth = 2
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
options.colors ??= true
|
|
257
|
-
|
|
258
|
-
const properties = {
|
|
259
|
-
status: this.status,
|
|
260
|
-
statusText: this.statusText,
|
|
261
|
-
headers: this.headers,
|
|
262
|
-
body: this.body,
|
|
263
|
-
bodyUsed: this.bodyUsed,
|
|
264
|
-
ok: this.ok,
|
|
265
|
-
redirected: this.redirected,
|
|
266
|
-
type: this.type,
|
|
267
|
-
url: this.url
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return `Response ${nodeUtil.formatWithOptions(options, properties)}`
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* @param {Response} response
|
|
275
|
-
*/
|
|
276
|
-
static getResponseHeaders (response) {
|
|
277
|
-
return response.#headers
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* @param {Response} response
|
|
282
|
-
* @param {Headers} newHeaders
|
|
283
|
-
*/
|
|
284
|
-
static setResponseHeaders (response, newHeaders) {
|
|
285
|
-
response.#headers = newHeaders
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @param {Response} response
|
|
290
|
-
*/
|
|
291
|
-
static getResponseState (response) {
|
|
292
|
-
return response.#state
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* @param {Response} response
|
|
297
|
-
* @param {any} newState
|
|
298
|
-
*/
|
|
299
|
-
static setResponseState (response, newState) {
|
|
300
|
-
response.#state = newState
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const { getResponseHeaders, setResponseHeaders, getResponseState, setResponseState } = Response
|
|
305
|
-
Reflect.deleteProperty(Response, 'getResponseHeaders')
|
|
306
|
-
Reflect.deleteProperty(Response, 'setResponseHeaders')
|
|
307
|
-
Reflect.deleteProperty(Response, 'getResponseState')
|
|
308
|
-
Reflect.deleteProperty(Response, 'setResponseState')
|
|
309
|
-
|
|
310
|
-
mixinBody(Response, getResponseState)
|
|
311
|
-
|
|
312
|
-
Object.defineProperties(Response.prototype, {
|
|
313
|
-
type: kEnumerableProperty,
|
|
314
|
-
url: kEnumerableProperty,
|
|
315
|
-
status: kEnumerableProperty,
|
|
316
|
-
ok: kEnumerableProperty,
|
|
317
|
-
redirected: kEnumerableProperty,
|
|
318
|
-
statusText: kEnumerableProperty,
|
|
319
|
-
headers: kEnumerableProperty,
|
|
320
|
-
clone: kEnumerableProperty,
|
|
321
|
-
body: kEnumerableProperty,
|
|
322
|
-
bodyUsed: kEnumerableProperty,
|
|
323
|
-
[Symbol.toStringTag]: {
|
|
324
|
-
value: 'Response',
|
|
325
|
-
configurable: true
|
|
326
|
-
}
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
Object.defineProperties(Response, {
|
|
330
|
-
json: kEnumerableProperty,
|
|
331
|
-
redirect: kEnumerableProperty,
|
|
332
|
-
error: kEnumerableProperty
|
|
333
|
-
})
|
|
334
|
-
|
|
335
|
-
// https://fetch.spec.whatwg.org/#concept-response-clone
|
|
336
|
-
function cloneResponse (response) {
|
|
337
|
-
// To clone a response response, run these steps:
|
|
338
|
-
|
|
339
|
-
// 1. If response is a filtered response, then return a new identical
|
|
340
|
-
// filtered response whose internal response is a clone of response’s
|
|
341
|
-
// internal response.
|
|
342
|
-
if (response.internalResponse) {
|
|
343
|
-
return filterResponse(
|
|
344
|
-
cloneResponse(response.internalResponse),
|
|
345
|
-
response.type
|
|
346
|
-
)
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// 2. Let newResponse be a copy of response, except for its body.
|
|
350
|
-
const newResponse = makeResponse({ ...response, body: null })
|
|
351
|
-
|
|
352
|
-
// 3. If response’s body is non-null, then set newResponse’s body to the
|
|
353
|
-
// result of cloning response’s body.
|
|
354
|
-
if (response.body != null) {
|
|
355
|
-
newResponse.body = cloneBody(newResponse, response.body)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// 4. Return newResponse.
|
|
359
|
-
return newResponse
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function makeResponse (init) {
|
|
363
|
-
return {
|
|
364
|
-
aborted: false,
|
|
365
|
-
rangeRequested: false,
|
|
366
|
-
timingAllowPassed: false,
|
|
367
|
-
requestIncludesCredentials: false,
|
|
368
|
-
type: 'default',
|
|
369
|
-
status: 200,
|
|
370
|
-
timingInfo: null,
|
|
371
|
-
cacheState: '',
|
|
372
|
-
statusText: '',
|
|
373
|
-
...init,
|
|
374
|
-
headersList: init?.headersList
|
|
375
|
-
? new HeadersList(init?.headersList)
|
|
376
|
-
: new HeadersList(),
|
|
377
|
-
urlList: init?.urlList ? [...init.urlList] : []
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
function makeNetworkError (reason) {
|
|
382
|
-
const isError = isErrorLike(reason)
|
|
383
|
-
return makeResponse({
|
|
384
|
-
type: 'error',
|
|
385
|
-
status: 0,
|
|
386
|
-
error: isError
|
|
387
|
-
? reason
|
|
388
|
-
: new Error(reason ? String(reason) : reason),
|
|
389
|
-
aborted: reason && reason.name === 'AbortError'
|
|
390
|
-
})
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// @see https://fetch.spec.whatwg.org/#concept-network-error
|
|
394
|
-
function isNetworkError (response) {
|
|
395
|
-
return (
|
|
396
|
-
// A network error is a response whose type is "error",
|
|
397
|
-
response.type === 'error' &&
|
|
398
|
-
// status is 0
|
|
399
|
-
response.status === 0
|
|
400
|
-
)
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function makeFilteredResponse (response, state) {
|
|
404
|
-
state = {
|
|
405
|
-
internalResponse: response,
|
|
406
|
-
...state
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return new Proxy(response, {
|
|
410
|
-
get (target, p) {
|
|
411
|
-
return p in state ? state[p] : target[p]
|
|
412
|
-
},
|
|
413
|
-
set (target, p, value) {
|
|
414
|
-
assert(!(p in state))
|
|
415
|
-
target[p] = value
|
|
416
|
-
return true
|
|
417
|
-
}
|
|
418
|
-
})
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// https://fetch.spec.whatwg.org/#concept-filtered-response
|
|
422
|
-
function filterResponse (response, type) {
|
|
423
|
-
// Set response to the following filtered response with response as its
|
|
424
|
-
// internal response, depending on request’s response tainting:
|
|
425
|
-
if (type === 'basic') {
|
|
426
|
-
// A basic filtered response is a filtered response whose type is "basic"
|
|
427
|
-
// and header list excludes any headers in internal response’s header list
|
|
428
|
-
// whose name is a forbidden response-header name.
|
|
429
|
-
|
|
430
|
-
// Note: undici does not implement forbidden response-header names
|
|
431
|
-
return makeFilteredResponse(response, {
|
|
432
|
-
type: 'basic',
|
|
433
|
-
headersList: response.headersList
|
|
434
|
-
})
|
|
435
|
-
} else if (type === 'cors') {
|
|
436
|
-
// A CORS filtered response is a filtered response whose type is "cors"
|
|
437
|
-
// and header list excludes any headers in internal response’s header
|
|
438
|
-
// list whose name is not a CORS-safelisted response-header name, given
|
|
439
|
-
// internal response’s CORS-exposed header-name list.
|
|
440
|
-
|
|
441
|
-
// Note: undici does not implement CORS-safelisted response-header names
|
|
442
|
-
return makeFilteredResponse(response, {
|
|
443
|
-
type: 'cors',
|
|
444
|
-
headersList: response.headersList
|
|
445
|
-
})
|
|
446
|
-
} else if (type === 'opaque') {
|
|
447
|
-
// An opaque filtered response is a filtered response whose type is
|
|
448
|
-
// "opaque", URL list is the empty list, status is 0, status message
|
|
449
|
-
// is the empty byte sequence, header list is empty, and body is null.
|
|
450
|
-
|
|
451
|
-
return makeFilteredResponse(response, {
|
|
452
|
-
type: 'opaque',
|
|
453
|
-
urlList: Object.freeze([]),
|
|
454
|
-
status: 0,
|
|
455
|
-
statusText: '',
|
|
456
|
-
body: null
|
|
457
|
-
})
|
|
458
|
-
} else if (type === 'opaqueredirect') {
|
|
459
|
-
// An opaque-redirect filtered response is a filtered response whose type
|
|
460
|
-
// is "opaqueredirect", status is 0, status message is the empty byte
|
|
461
|
-
// sequence, header list is empty, and body is null.
|
|
462
|
-
|
|
463
|
-
return makeFilteredResponse(response, {
|
|
464
|
-
type: 'opaqueredirect',
|
|
465
|
-
status: 0,
|
|
466
|
-
statusText: '',
|
|
467
|
-
headersList: [],
|
|
468
|
-
body: null
|
|
469
|
-
})
|
|
470
|
-
} else {
|
|
471
|
-
assert(false)
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// https://fetch.spec.whatwg.org/#appropriate-network-error
|
|
476
|
-
function makeAppropriateNetworkError (fetchParams, err = null) {
|
|
477
|
-
// 1. Assert: fetchParams is canceled.
|
|
478
|
-
assert(isCancelled(fetchParams))
|
|
479
|
-
|
|
480
|
-
// 2. Return an aborted network error if fetchParams is aborted;
|
|
481
|
-
// otherwise return a network error.
|
|
482
|
-
return isAborted(fetchParams)
|
|
483
|
-
? makeNetworkError(Object.assign(new DOMException('The operation was aborted.', 'AbortError'), { cause: err }))
|
|
484
|
-
: makeNetworkError(Object.assign(new DOMException('Request was cancelled.'), { cause: err }))
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// https://whatpr.org/fetch/1392.html#initialize-a-response
|
|
488
|
-
function initializeResponse (response, init, body) {
|
|
489
|
-
// 1. If init["status"] is not in the range 200 to 599, inclusive, then
|
|
490
|
-
// throw a RangeError.
|
|
491
|
-
if (init.status !== null && (init.status < 200 || init.status > 599)) {
|
|
492
|
-
throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.')
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// 2. If init["statusText"] does not match the reason-phrase token production,
|
|
496
|
-
// then throw a TypeError.
|
|
497
|
-
if ('statusText' in init && init.statusText != null) {
|
|
498
|
-
// See, https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2:
|
|
499
|
-
// reason-phrase = *( HTAB / SP / VCHAR / obs-text )
|
|
500
|
-
if (!isValidReasonPhrase(String(init.statusText))) {
|
|
501
|
-
throw new TypeError('Invalid statusText')
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// 3. Set response’s response’s status to init["status"].
|
|
506
|
-
if ('status' in init && init.status != null) {
|
|
507
|
-
getResponseState(response).status = init.status
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// 4. Set response’s response’s status message to init["statusText"].
|
|
511
|
-
if ('statusText' in init && init.statusText != null) {
|
|
512
|
-
getResponseState(response).statusText = init.statusText
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// 5. If init["headers"] exists, then fill response’s headers with init["headers"].
|
|
516
|
-
if ('headers' in init && init.headers != null) {
|
|
517
|
-
fill(getResponseHeaders(response), init.headers)
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// 6. If body was given, then:
|
|
521
|
-
if (body) {
|
|
522
|
-
// 1. If response's status is a null body status, then throw a TypeError.
|
|
523
|
-
if (nullBodyStatus.includes(response.status)) {
|
|
524
|
-
throw webidl.errors.exception({
|
|
525
|
-
header: 'Response constructor',
|
|
526
|
-
message: `Invalid response status code ${response.status}`
|
|
527
|
-
})
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// 2. Set response's body to body's body.
|
|
531
|
-
getResponseState(response).body = body.body
|
|
532
|
-
|
|
533
|
-
// 3. If body's type is non-null and response's header list does not contain
|
|
534
|
-
// `Content-Type`, then append (`Content-Type`, body's type) to response's header list.
|
|
535
|
-
if (body.type != null && !getResponseState(response).headersList.contains('content-type', true)) {
|
|
536
|
-
getResponseState(response).headersList.append('content-type', body.type, true)
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* @see https://fetch.spec.whatwg.org/#response-create
|
|
543
|
-
* @param {any} innerResponse
|
|
544
|
-
* @param {'request' | 'immutable' | 'request-no-cors' | 'response' | 'none'} guard
|
|
545
|
-
* @returns {Response}
|
|
546
|
-
*/
|
|
547
|
-
function fromInnerResponse (innerResponse, guard) {
|
|
548
|
-
const response = new Response(kConstruct)
|
|
549
|
-
setResponseState(response, innerResponse)
|
|
550
|
-
const headers = new Headers(kConstruct)
|
|
551
|
-
setResponseHeaders(response, headers)
|
|
552
|
-
setHeadersList(headers, innerResponse.headersList)
|
|
553
|
-
setHeadersGuard(headers, guard)
|
|
554
|
-
|
|
555
|
-
if (hasFinalizationRegistry && innerResponse.body?.stream) {
|
|
556
|
-
// If the target (response) is reclaimed, the cleanup callback may be called at some point with
|
|
557
|
-
// the held value provided for it (innerResponse.body.stream). The held value can be any value:
|
|
558
|
-
// a primitive or an object, even undefined. If the held value is an object, the registry keeps
|
|
559
|
-
// a strong reference to it (so it can pass it to the cleanup callback later). Reworded from
|
|
560
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
|
|
561
|
-
streamRegistry.register(response, new WeakRef(innerResponse.body.stream))
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
return response
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
|
|
568
|
-
webidl.converters.XMLHttpRequestBodyInit = function (V, prefix, name) {
|
|
569
|
-
if (typeof V === 'string') {
|
|
570
|
-
return webidl.converters.USVString(V, prefix, name)
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if (webidl.is.Blob(V)) {
|
|
574
|
-
return V
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
if (ArrayBuffer.isView(V) || types.isArrayBuffer(V)) {
|
|
578
|
-
return V
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if (webidl.is.FormData(V)) {
|
|
582
|
-
return V
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
if (webidl.is.URLSearchParams(V)) {
|
|
586
|
-
return V
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
return webidl.converters.DOMString(V, prefix, name)
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// https://fetch.spec.whatwg.org/#bodyinit
|
|
593
|
-
webidl.converters.BodyInit = function (V, prefix, argument) {
|
|
594
|
-
if (webidl.is.ReadableStream(V)) {
|
|
595
|
-
return V
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// Note: the spec doesn't include async iterables,
|
|
599
|
-
// this is an undici extension.
|
|
600
|
-
if (V?.[Symbol.asyncIterator]) {
|
|
601
|
-
return V
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
return webidl.converters.XMLHttpRequestBodyInit(V, prefix, argument)
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
webidl.converters.ResponseInit = webidl.dictionaryConverter([
|
|
608
|
-
{
|
|
609
|
-
key: 'status',
|
|
610
|
-
converter: webidl.converters['unsigned short'],
|
|
611
|
-
defaultValue: () => 200
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
key: 'statusText',
|
|
615
|
-
converter: webidl.converters.ByteString,
|
|
616
|
-
defaultValue: () => ''
|
|
617
|
-
},
|
|
618
|
-
{
|
|
619
|
-
key: 'headers',
|
|
620
|
-
converter: webidl.converters.HeadersInit
|
|
621
|
-
}
|
|
622
|
-
])
|
|
623
|
-
|
|
624
|
-
webidl.is.Response = webidl.util.MakeTypeAssertion(Response)
|
|
625
|
-
|
|
626
|
-
module.exports = {
|
|
627
|
-
isNetworkError,
|
|
628
|
-
makeNetworkError,
|
|
629
|
-
makeResponse,
|
|
630
|
-
makeAppropriateNetworkError,
|
|
631
|
-
filterResponse,
|
|
632
|
-
Response,
|
|
633
|
-
cloneResponse,
|
|
634
|
-
fromInnerResponse,
|
|
635
|
-
getResponseState
|
|
636
|
-
}
|