undici 6.19.8 → 7.0.0-alpha.1

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.
Files changed (115) hide show
  1. package/README.md +5 -9
  2. package/docs/docs/api/Agent.md +0 -3
  3. package/docs/docs/api/Client.md +0 -2
  4. package/docs/docs/api/Dispatcher.md +204 -6
  5. package/docs/docs/api/EnvHttpProxyAgent.md +0 -1
  6. package/docs/docs/api/Fetch.md +1 -0
  7. package/docs/docs/api/Pool.md +0 -1
  8. package/docs/docs/api/RetryHandler.md +1 -1
  9. package/index.js +0 -4
  10. package/lib/api/api-connect.js +3 -1
  11. package/lib/api/api-pipeline.js +3 -4
  12. package/lib/api/api-request.js +29 -46
  13. package/lib/api/api-stream.js +36 -49
  14. package/lib/api/api-upgrade.js +5 -3
  15. package/lib/api/readable.js +71 -27
  16. package/lib/core/connect.js +39 -24
  17. package/lib/core/errors.js +17 -4
  18. package/lib/core/request.js +7 -5
  19. package/lib/core/symbols.js +0 -1
  20. package/lib/core/tree.js +6 -0
  21. package/lib/core/util.js +1 -11
  22. package/lib/dispatcher/agent.js +3 -17
  23. package/lib/dispatcher/balanced-pool.js +5 -8
  24. package/lib/dispatcher/client-h1.js +44 -39
  25. package/lib/dispatcher/client.js +3 -27
  26. package/lib/dispatcher/dispatcher-base.js +2 -34
  27. package/lib/dispatcher/dispatcher.js +3 -24
  28. package/lib/dispatcher/pool.js +3 -6
  29. package/lib/dispatcher/proxy-agent.js +3 -6
  30. package/lib/handler/decorator-handler.js +24 -0
  31. package/lib/handler/redirect-handler.js +9 -0
  32. package/lib/handler/retry-handler.js +22 -3
  33. package/lib/interceptor/dump.js +2 -2
  34. package/lib/interceptor/redirect.js +11 -14
  35. package/lib/interceptor/response-error.js +89 -0
  36. package/lib/llhttp/constants.d.ts +97 -0
  37. package/lib/llhttp/constants.js +412 -192
  38. package/lib/llhttp/constants.js.map +1 -0
  39. package/lib/llhttp/llhttp-wasm.js +11 -1
  40. package/lib/llhttp/llhttp_simd-wasm.js +11 -1
  41. package/lib/llhttp/utils.d.ts +2 -0
  42. package/lib/llhttp/utils.js +9 -9
  43. package/lib/llhttp/utils.js.map +1 -0
  44. package/lib/mock/mock-client.js +2 -2
  45. package/lib/mock/mock-pool.js +2 -2
  46. package/lib/mock/mock-symbols.js +1 -0
  47. package/lib/util/timers.js +324 -44
  48. package/lib/web/cookies/index.js +15 -13
  49. package/lib/web/cookies/parse.js +2 -2
  50. package/lib/web/eventsource/eventsource-stream.js +9 -8
  51. package/lib/web/eventsource/eventsource.js +10 -6
  52. package/lib/web/fetch/body.js +4 -6
  53. package/lib/web/fetch/data-url.js +1 -1
  54. package/lib/web/fetch/formdata-parser.js +1 -2
  55. package/lib/web/fetch/formdata.js +28 -37
  56. package/lib/web/fetch/headers.js +1 -1
  57. package/lib/web/fetch/index.js +7 -8
  58. package/lib/web/fetch/request.js +7 -24
  59. package/lib/web/fetch/response.js +9 -22
  60. package/lib/web/fetch/symbols.js +0 -1
  61. package/lib/web/fetch/util.js +3 -12
  62. package/lib/web/fetch/webidl.js +73 -62
  63. package/lib/web/websocket/connection.js +26 -174
  64. package/lib/web/websocket/constants.js +1 -1
  65. package/lib/web/websocket/frame.js +45 -3
  66. package/lib/web/websocket/receiver.js +28 -26
  67. package/lib/web/websocket/sender.js +18 -13
  68. package/lib/web/websocket/util.js +20 -74
  69. package/lib/web/websocket/websocket.js +294 -70
  70. package/package.json +16 -29
  71. package/scripts/strip-comments.js +3 -1
  72. package/types/agent.d.ts +7 -7
  73. package/types/api.d.ts +24 -24
  74. package/types/balanced-pool.d.ts +11 -11
  75. package/types/client.d.ts +11 -12
  76. package/types/diagnostics-channel.d.ts +10 -10
  77. package/types/dispatcher.d.ts +96 -97
  78. package/types/env-http-proxy-agent.d.ts +2 -2
  79. package/types/errors.d.ts +53 -47
  80. package/types/eventsource.d.ts +0 -2
  81. package/types/fetch.d.ts +8 -8
  82. package/types/formdata.d.ts +7 -7
  83. package/types/global-dispatcher.d.ts +4 -4
  84. package/types/global-origin.d.ts +5 -5
  85. package/types/handlers.d.ts +4 -4
  86. package/types/header.d.ts +157 -1
  87. package/types/index.d.ts +42 -46
  88. package/types/interceptors.d.ts +10 -8
  89. package/types/mock-agent.d.ts +18 -18
  90. package/types/mock-client.d.ts +4 -4
  91. package/types/mock-errors.d.ts +3 -3
  92. package/types/mock-interceptor.d.ts +19 -19
  93. package/types/mock-pool.d.ts +4 -4
  94. package/types/patch.d.ts +0 -42
  95. package/types/pool-stats.d.ts +8 -8
  96. package/types/pool.d.ts +12 -12
  97. package/types/proxy-agent.d.ts +4 -4
  98. package/types/readable.d.ts +14 -9
  99. package/types/retry-agent.d.ts +1 -1
  100. package/types/retry-handler.d.ts +8 -8
  101. package/types/util.d.ts +3 -3
  102. package/types/utility.d.ts +7 -0
  103. package/types/webidl.d.ts +22 -4
  104. package/types/websocket.d.ts +1 -3
  105. package/docs/docs/api/DispatchInterceptor.md +0 -60
  106. package/lib/interceptor/redirect-interceptor.js +0 -21
  107. package/lib/web/fetch/file.js +0 -126
  108. package/lib/web/fileapi/encoding.js +0 -290
  109. package/lib/web/fileapi/filereader.js +0 -344
  110. package/lib/web/fileapi/progressevent.js +0 -78
  111. package/lib/web/fileapi/symbols.js +0 -10
  112. package/lib/web/fileapi/util.js +0 -391
  113. package/lib/web/websocket/symbols.js +0 -12
  114. package/types/file.d.ts +0 -39
  115. package/types/filereader.d.ts +0 -54
@@ -1,126 +0,0 @@
1
- 'use strict'
2
-
3
- const { Blob, File } = require('node:buffer')
4
- const { kState } = require('./symbols')
5
- const { webidl } = require('./webidl')
6
-
7
- // TODO(@KhafraDev): remove
8
- class FileLike {
9
- constructor (blobLike, fileName, options = {}) {
10
- // TODO: argument idl type check
11
-
12
- // The File constructor is invoked with two or three parameters, depending
13
- // on whether the optional dictionary parameter is used. When the File()
14
- // constructor is invoked, user agents must run the following steps:
15
-
16
- // 1. Let bytes be the result of processing blob parts given fileBits and
17
- // options.
18
-
19
- // 2. Let n be the fileName argument to the constructor.
20
- const n = fileName
21
-
22
- // 3. Process FilePropertyBag dictionary argument by running the following
23
- // substeps:
24
-
25
- // 1. If the type member is provided and is not the empty string, let t
26
- // be set to the type dictionary member. If t contains any characters
27
- // outside the range U+0020 to U+007E, then set t to the empty string
28
- // and return from these substeps.
29
- // TODO
30
- const t = options.type
31
-
32
- // 2. Convert every character in t to ASCII lowercase.
33
- // TODO
34
-
35
- // 3. If the lastModified member is provided, let d be set to the
36
- // lastModified dictionary member. If it is not provided, set d to the
37
- // current date and time represented as the number of milliseconds since
38
- // the Unix Epoch (which is the equivalent of Date.now() [ECMA-262]).
39
- const d = options.lastModified ?? Date.now()
40
-
41
- // 4. Return a new File object F such that:
42
- // F refers to the bytes byte sequence.
43
- // F.size is set to the number of total bytes in bytes.
44
- // F.name is set to n.
45
- // F.type is set to t.
46
- // F.lastModified is set to d.
47
-
48
- this[kState] = {
49
- blobLike,
50
- name: n,
51
- type: t,
52
- lastModified: d
53
- }
54
- }
55
-
56
- stream (...args) {
57
- webidl.brandCheck(this, FileLike)
58
-
59
- return this[kState].blobLike.stream(...args)
60
- }
61
-
62
- arrayBuffer (...args) {
63
- webidl.brandCheck(this, FileLike)
64
-
65
- return this[kState].blobLike.arrayBuffer(...args)
66
- }
67
-
68
- slice (...args) {
69
- webidl.brandCheck(this, FileLike)
70
-
71
- return this[kState].blobLike.slice(...args)
72
- }
73
-
74
- text (...args) {
75
- webidl.brandCheck(this, FileLike)
76
-
77
- return this[kState].blobLike.text(...args)
78
- }
79
-
80
- get size () {
81
- webidl.brandCheck(this, FileLike)
82
-
83
- return this[kState].blobLike.size
84
- }
85
-
86
- get type () {
87
- webidl.brandCheck(this, FileLike)
88
-
89
- return this[kState].blobLike.type
90
- }
91
-
92
- get name () {
93
- webidl.brandCheck(this, FileLike)
94
-
95
- return this[kState].name
96
- }
97
-
98
- get lastModified () {
99
- webidl.brandCheck(this, FileLike)
100
-
101
- return this[kState].lastModified
102
- }
103
-
104
- get [Symbol.toStringTag] () {
105
- return 'File'
106
- }
107
- }
108
-
109
- webidl.converters.Blob = webidl.interfaceConverter(Blob)
110
-
111
- // If this function is moved to ./util.js, some tools (such as
112
- // rollup) will warn about circular dependencies. See:
113
- // https://github.com/nodejs/undici/issues/1629
114
- function isFileLike (object) {
115
- return (
116
- (object instanceof File) ||
117
- (
118
- object &&
119
- (typeof object.stream === 'function' ||
120
- typeof object.arrayBuffer === 'function') &&
121
- object[Symbol.toStringTag] === 'File'
122
- )
123
- )
124
- }
125
-
126
- module.exports = { FileLike, isFileLike }
@@ -1,290 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @see https://encoding.spec.whatwg.org/#concept-encoding-get
5
- * @param {string|undefined} label
6
- */
7
- function getEncoding (label) {
8
- if (!label) {
9
- return 'failure'
10
- }
11
-
12
- // 1. Remove any leading and trailing ASCII whitespace from label.
13
- // 2. If label is an ASCII case-insensitive match for any of the
14
- // labels listed in the table below, then return the
15
- // corresponding encoding; otherwise return failure.
16
- switch (label.trim().toLowerCase()) {
17
- case 'unicode-1-1-utf-8':
18
- case 'unicode11utf8':
19
- case 'unicode20utf8':
20
- case 'utf-8':
21
- case 'utf8':
22
- case 'x-unicode20utf8':
23
- return 'UTF-8'
24
- case '866':
25
- case 'cp866':
26
- case 'csibm866':
27
- case 'ibm866':
28
- return 'IBM866'
29
- case 'csisolatin2':
30
- case 'iso-8859-2':
31
- case 'iso-ir-101':
32
- case 'iso8859-2':
33
- case 'iso88592':
34
- case 'iso_8859-2':
35
- case 'iso_8859-2:1987':
36
- case 'l2':
37
- case 'latin2':
38
- return 'ISO-8859-2'
39
- case 'csisolatin3':
40
- case 'iso-8859-3':
41
- case 'iso-ir-109':
42
- case 'iso8859-3':
43
- case 'iso88593':
44
- case 'iso_8859-3':
45
- case 'iso_8859-3:1988':
46
- case 'l3':
47
- case 'latin3':
48
- return 'ISO-8859-3'
49
- case 'csisolatin4':
50
- case 'iso-8859-4':
51
- case 'iso-ir-110':
52
- case 'iso8859-4':
53
- case 'iso88594':
54
- case 'iso_8859-4':
55
- case 'iso_8859-4:1988':
56
- case 'l4':
57
- case 'latin4':
58
- return 'ISO-8859-4'
59
- case 'csisolatincyrillic':
60
- case 'cyrillic':
61
- case 'iso-8859-5':
62
- case 'iso-ir-144':
63
- case 'iso8859-5':
64
- case 'iso88595':
65
- case 'iso_8859-5':
66
- case 'iso_8859-5:1988':
67
- return 'ISO-8859-5'
68
- case 'arabic':
69
- case 'asmo-708':
70
- case 'csiso88596e':
71
- case 'csiso88596i':
72
- case 'csisolatinarabic':
73
- case 'ecma-114':
74
- case 'iso-8859-6':
75
- case 'iso-8859-6-e':
76
- case 'iso-8859-6-i':
77
- case 'iso-ir-127':
78
- case 'iso8859-6':
79
- case 'iso88596':
80
- case 'iso_8859-6':
81
- case 'iso_8859-6:1987':
82
- return 'ISO-8859-6'
83
- case 'csisolatingreek':
84
- case 'ecma-118':
85
- case 'elot_928':
86
- case 'greek':
87
- case 'greek8':
88
- case 'iso-8859-7':
89
- case 'iso-ir-126':
90
- case 'iso8859-7':
91
- case 'iso88597':
92
- case 'iso_8859-7':
93
- case 'iso_8859-7:1987':
94
- case 'sun_eu_greek':
95
- return 'ISO-8859-7'
96
- case 'csiso88598e':
97
- case 'csisolatinhebrew':
98
- case 'hebrew':
99
- case 'iso-8859-8':
100
- case 'iso-8859-8-e':
101
- case 'iso-ir-138':
102
- case 'iso8859-8':
103
- case 'iso88598':
104
- case 'iso_8859-8':
105
- case 'iso_8859-8:1988':
106
- case 'visual':
107
- return 'ISO-8859-8'
108
- case 'csiso88598i':
109
- case 'iso-8859-8-i':
110
- case 'logical':
111
- return 'ISO-8859-8-I'
112
- case 'csisolatin6':
113
- case 'iso-8859-10':
114
- case 'iso-ir-157':
115
- case 'iso8859-10':
116
- case 'iso885910':
117
- case 'l6':
118
- case 'latin6':
119
- return 'ISO-8859-10'
120
- case 'iso-8859-13':
121
- case 'iso8859-13':
122
- case 'iso885913':
123
- return 'ISO-8859-13'
124
- case 'iso-8859-14':
125
- case 'iso8859-14':
126
- case 'iso885914':
127
- return 'ISO-8859-14'
128
- case 'csisolatin9':
129
- case 'iso-8859-15':
130
- case 'iso8859-15':
131
- case 'iso885915':
132
- case 'iso_8859-15':
133
- case 'l9':
134
- return 'ISO-8859-15'
135
- case 'iso-8859-16':
136
- return 'ISO-8859-16'
137
- case 'cskoi8r':
138
- case 'koi':
139
- case 'koi8':
140
- case 'koi8-r':
141
- case 'koi8_r':
142
- return 'KOI8-R'
143
- case 'koi8-ru':
144
- case 'koi8-u':
145
- return 'KOI8-U'
146
- case 'csmacintosh':
147
- case 'mac':
148
- case 'macintosh':
149
- case 'x-mac-roman':
150
- return 'macintosh'
151
- case 'iso-8859-11':
152
- case 'iso8859-11':
153
- case 'iso885911':
154
- case 'tis-620':
155
- case 'windows-874':
156
- return 'windows-874'
157
- case 'cp1250':
158
- case 'windows-1250':
159
- case 'x-cp1250':
160
- return 'windows-1250'
161
- case 'cp1251':
162
- case 'windows-1251':
163
- case 'x-cp1251':
164
- return 'windows-1251'
165
- case 'ansi_x3.4-1968':
166
- case 'ascii':
167
- case 'cp1252':
168
- case 'cp819':
169
- case 'csisolatin1':
170
- case 'ibm819':
171
- case 'iso-8859-1':
172
- case 'iso-ir-100':
173
- case 'iso8859-1':
174
- case 'iso88591':
175
- case 'iso_8859-1':
176
- case 'iso_8859-1:1987':
177
- case 'l1':
178
- case 'latin1':
179
- case 'us-ascii':
180
- case 'windows-1252':
181
- case 'x-cp1252':
182
- return 'windows-1252'
183
- case 'cp1253':
184
- case 'windows-1253':
185
- case 'x-cp1253':
186
- return 'windows-1253'
187
- case 'cp1254':
188
- case 'csisolatin5':
189
- case 'iso-8859-9':
190
- case 'iso-ir-148':
191
- case 'iso8859-9':
192
- case 'iso88599':
193
- case 'iso_8859-9':
194
- case 'iso_8859-9:1989':
195
- case 'l5':
196
- case 'latin5':
197
- case 'windows-1254':
198
- case 'x-cp1254':
199
- return 'windows-1254'
200
- case 'cp1255':
201
- case 'windows-1255':
202
- case 'x-cp1255':
203
- return 'windows-1255'
204
- case 'cp1256':
205
- case 'windows-1256':
206
- case 'x-cp1256':
207
- return 'windows-1256'
208
- case 'cp1257':
209
- case 'windows-1257':
210
- case 'x-cp1257':
211
- return 'windows-1257'
212
- case 'cp1258':
213
- case 'windows-1258':
214
- case 'x-cp1258':
215
- return 'windows-1258'
216
- case 'x-mac-cyrillic':
217
- case 'x-mac-ukrainian':
218
- return 'x-mac-cyrillic'
219
- case 'chinese':
220
- case 'csgb2312':
221
- case 'csiso58gb231280':
222
- case 'gb2312':
223
- case 'gb_2312':
224
- case 'gb_2312-80':
225
- case 'gbk':
226
- case 'iso-ir-58':
227
- case 'x-gbk':
228
- return 'GBK'
229
- case 'gb18030':
230
- return 'gb18030'
231
- case 'big5':
232
- case 'big5-hkscs':
233
- case 'cn-big5':
234
- case 'csbig5':
235
- case 'x-x-big5':
236
- return 'Big5'
237
- case 'cseucpkdfmtjapanese':
238
- case 'euc-jp':
239
- case 'x-euc-jp':
240
- return 'EUC-JP'
241
- case 'csiso2022jp':
242
- case 'iso-2022-jp':
243
- return 'ISO-2022-JP'
244
- case 'csshiftjis':
245
- case 'ms932':
246
- case 'ms_kanji':
247
- case 'shift-jis':
248
- case 'shift_jis':
249
- case 'sjis':
250
- case 'windows-31j':
251
- case 'x-sjis':
252
- return 'Shift_JIS'
253
- case 'cseuckr':
254
- case 'csksc56011987':
255
- case 'euc-kr':
256
- case 'iso-ir-149':
257
- case 'korean':
258
- case 'ks_c_5601-1987':
259
- case 'ks_c_5601-1989':
260
- case 'ksc5601':
261
- case 'ksc_5601':
262
- case 'windows-949':
263
- return 'EUC-KR'
264
- case 'csiso2022kr':
265
- case 'hz-gb-2312':
266
- case 'iso-2022-cn':
267
- case 'iso-2022-cn-ext':
268
- case 'iso-2022-kr':
269
- case 'replacement':
270
- return 'replacement'
271
- case 'unicodefffe':
272
- case 'utf-16be':
273
- return 'UTF-16BE'
274
- case 'csunicode':
275
- case 'iso-10646-ucs-2':
276
- case 'ucs-2':
277
- case 'unicode':
278
- case 'unicodefeff':
279
- case 'utf-16':
280
- case 'utf-16le':
281
- return 'UTF-16LE'
282
- case 'x-user-defined':
283
- return 'x-user-defined'
284
- default: return 'failure'
285
- }
286
- }
287
-
288
- module.exports = {
289
- getEncoding
290
- }