deepv-code 1.0.182 → 1.0.183

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 (193) hide show
  1. package/bundle/dvcode.js +635 -635
  2. package/package.json +1 -1
  3. package/bundle/assets/help/README.md +0 -113
  4. package/bundle/assets/sounds/README.md +0 -74
  5. package/bundle/node_modules/undici/LICENSE +0 -21
  6. package/bundle/node_modules/undici/README.md +0 -472
  7. package/bundle/node_modules/undici/docs/docs/api/Agent.md +0 -83
  8. package/bundle/node_modules/undici/docs/docs/api/BalancedPool.md +0 -99
  9. package/bundle/node_modules/undici/docs/docs/api/CacheStorage.md +0 -30
  10. package/bundle/node_modules/undici/docs/docs/api/CacheStore.md +0 -151
  11. package/bundle/node_modules/undici/docs/docs/api/Client.md +0 -281
  12. package/bundle/node_modules/undici/docs/docs/api/ClientStats.md +0 -27
  13. package/bundle/node_modules/undici/docs/docs/api/Connector.md +0 -115
  14. package/bundle/node_modules/undici/docs/docs/api/ContentType.md +0 -57
  15. package/bundle/node_modules/undici/docs/docs/api/Cookies.md +0 -101
  16. package/bundle/node_modules/undici/docs/docs/api/Debug.md +0 -62
  17. package/bundle/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +0 -204
  18. package/bundle/node_modules/undici/docs/docs/api/Dispatcher.md +0 -1200
  19. package/bundle/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +0 -159
  20. package/bundle/node_modules/undici/docs/docs/api/Errors.md +0 -49
  21. package/bundle/node_modules/undici/docs/docs/api/EventSource.md +0 -45
  22. package/bundle/node_modules/undici/docs/docs/api/Fetch.md +0 -52
  23. package/bundle/node_modules/undici/docs/docs/api/H2CClient.md +0 -262
  24. package/bundle/node_modules/undici/docs/docs/api/MockAgent.md +0 -603
  25. package/bundle/node_modules/undici/docs/docs/api/MockCallHistory.md +0 -197
  26. package/bundle/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +0 -43
  27. package/bundle/node_modules/undici/docs/docs/api/MockClient.md +0 -77
  28. package/bundle/node_modules/undici/docs/docs/api/MockErrors.md +0 -12
  29. package/bundle/node_modules/undici/docs/docs/api/MockPool.md +0 -548
  30. package/bundle/node_modules/undici/docs/docs/api/Pool.md +0 -84
  31. package/bundle/node_modules/undici/docs/docs/api/PoolStats.md +0 -35
  32. package/bundle/node_modules/undici/docs/docs/api/ProxyAgent.md +0 -227
  33. package/bundle/node_modules/undici/docs/docs/api/RedirectHandler.md +0 -96
  34. package/bundle/node_modules/undici/docs/docs/api/RetryAgent.md +0 -45
  35. package/bundle/node_modules/undici/docs/docs/api/RetryHandler.md +0 -117
  36. package/bundle/node_modules/undici/docs/docs/api/Util.md +0 -25
  37. package/bundle/node_modules/undici/docs/docs/api/WebSocket.md +0 -85
  38. package/bundle/node_modules/undici/docs/docs/api/api-lifecycle.md +0 -91
  39. package/bundle/node_modules/undici/docs/docs/best-practices/client-certificate.md +0 -64
  40. package/bundle/node_modules/undici/docs/docs/best-practices/mocking-request.md +0 -190
  41. package/bundle/node_modules/undici/docs/docs/best-practices/proxy.md +0 -127
  42. package/bundle/node_modules/undici/docs/docs/best-practices/writing-tests.md +0 -20
  43. package/bundle/node_modules/undici/index-fetch.js +0 -35
  44. package/bundle/node_modules/undici/index.d.ts +0 -3
  45. package/bundle/node_modules/undici/index.js +0 -183
  46. package/bundle/node_modules/undici/lib/api/abort-signal.js +0 -59
  47. package/bundle/node_modules/undici/lib/api/api-connect.js +0 -110
  48. package/bundle/node_modules/undici/lib/api/api-pipeline.js +0 -252
  49. package/bundle/node_modules/undici/lib/api/api-request.js +0 -199
  50. package/bundle/node_modules/undici/lib/api/api-stream.js +0 -209
  51. package/bundle/node_modules/undici/lib/api/api-upgrade.js +0 -110
  52. package/bundle/node_modules/undici/lib/api/index.js +0 -7
  53. package/bundle/node_modules/undici/lib/api/readable.js +0 -558
  54. package/bundle/node_modules/undici/lib/api/util.js +0 -95
  55. package/bundle/node_modules/undici/lib/cache/memory-cache-store.js +0 -234
  56. package/bundle/node_modules/undici/lib/cache/sqlite-cache-store.js +0 -461
  57. package/bundle/node_modules/undici/lib/core/connect.js +0 -164
  58. package/bundle/node_modules/undici/lib/core/constants.js +0 -143
  59. package/bundle/node_modules/undici/lib/core/diagnostics.js +0 -196
  60. package/bundle/node_modules/undici/lib/core/errors.js +0 -244
  61. package/bundle/node_modules/undici/lib/core/request.js +0 -397
  62. package/bundle/node_modules/undici/lib/core/symbols.js +0 -68
  63. package/bundle/node_modules/undici/lib/core/tree.js +0 -160
  64. package/bundle/node_modules/undici/lib/core/util.js +0 -988
  65. package/bundle/node_modules/undici/lib/dispatcher/agent.js +0 -135
  66. package/bundle/node_modules/undici/lib/dispatcher/balanced-pool.js +0 -206
  67. package/bundle/node_modules/undici/lib/dispatcher/client-h1.js +0 -1615
  68. package/bundle/node_modules/undici/lib/dispatcher/client-h2.js +0 -798
  69. package/bundle/node_modules/undici/lib/dispatcher/client.js +0 -614
  70. package/bundle/node_modules/undici/lib/dispatcher/dispatcher-base.js +0 -161
  71. package/bundle/node_modules/undici/lib/dispatcher/dispatcher.js +0 -48
  72. package/bundle/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +0 -151
  73. package/bundle/node_modules/undici/lib/dispatcher/fixed-queue.js +0 -159
  74. package/bundle/node_modules/undici/lib/dispatcher/h2c-client.js +0 -122
  75. package/bundle/node_modules/undici/lib/dispatcher/pool-base.js +0 -191
  76. package/bundle/node_modules/undici/lib/dispatcher/pool.js +0 -118
  77. package/bundle/node_modules/undici/lib/dispatcher/proxy-agent.js +0 -275
  78. package/bundle/node_modules/undici/lib/dispatcher/retry-agent.js +0 -35
  79. package/bundle/node_modules/undici/lib/global.js +0 -32
  80. package/bundle/node_modules/undici/lib/handler/cache-handler.js +0 -448
  81. package/bundle/node_modules/undici/lib/handler/cache-revalidation-handler.js +0 -124
  82. package/bundle/node_modules/undici/lib/handler/decorator-handler.js +0 -67
  83. package/bundle/node_modules/undici/lib/handler/redirect-handler.js +0 -227
  84. package/bundle/node_modules/undici/lib/handler/retry-handler.js +0 -342
  85. package/bundle/node_modules/undici/lib/handler/unwrap-handler.js +0 -96
  86. package/bundle/node_modules/undici/lib/handler/wrap-handler.js +0 -95
  87. package/bundle/node_modules/undici/lib/interceptor/cache.js +0 -372
  88. package/bundle/node_modules/undici/lib/interceptor/dns.js +0 -432
  89. package/bundle/node_modules/undici/lib/interceptor/dump.js +0 -111
  90. package/bundle/node_modules/undici/lib/interceptor/redirect.js +0 -21
  91. package/bundle/node_modules/undici/lib/interceptor/response-error.js +0 -95
  92. package/bundle/node_modules/undici/lib/interceptor/retry.js +0 -19
  93. package/bundle/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  94. package/bundle/node_modules/undici/lib/llhttp/constants.d.ts +0 -97
  95. package/bundle/node_modules/undici/lib/llhttp/constants.js +0 -498
  96. package/bundle/node_modules/undici/lib/llhttp/constants.js.map +0 -1
  97. package/bundle/node_modules/undici/lib/llhttp/llhttp-wasm.js +0 -15
  98. package/bundle/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +0 -15
  99. package/bundle/node_modules/undici/lib/llhttp/utils.d.ts +0 -2
  100. package/bundle/node_modules/undici/lib/llhttp/utils.js +0 -15
  101. package/bundle/node_modules/undici/lib/llhttp/utils.js.map +0 -1
  102. package/bundle/node_modules/undici/lib/mock/mock-agent.js +0 -224
  103. package/bundle/node_modules/undici/lib/mock/mock-call-history.js +0 -248
  104. package/bundle/node_modules/undici/lib/mock/mock-client.js +0 -64
  105. package/bundle/node_modules/undici/lib/mock/mock-errors.js +0 -19
  106. package/bundle/node_modules/undici/lib/mock/mock-interceptor.js +0 -209
  107. package/bundle/node_modules/undici/lib/mock/mock-pool.js +0 -64
  108. package/bundle/node_modules/undici/lib/mock/mock-symbols.js +0 -31
  109. package/bundle/node_modules/undici/lib/mock/mock-utils.js +0 -433
  110. package/bundle/node_modules/undici/lib/mock/pending-interceptors-formatter.js +0 -43
  111. package/bundle/node_modules/undici/lib/util/cache.js +0 -368
  112. package/bundle/node_modules/undici/lib/util/date.js +0 -259
  113. package/bundle/node_modules/undici/lib/util/stats.js +0 -32
  114. package/bundle/node_modules/undici/lib/util/timers.js +0 -423
  115. package/bundle/node_modules/undici/lib/web/cache/cache.js +0 -862
  116. package/bundle/node_modules/undici/lib/web/cache/cachestorage.js +0 -152
  117. package/bundle/node_modules/undici/lib/web/cache/util.js +0 -45
  118. package/bundle/node_modules/undici/lib/web/cookies/constants.js +0 -12
  119. package/bundle/node_modules/undici/lib/web/cookies/index.js +0 -199
  120. package/bundle/node_modules/undici/lib/web/cookies/parse.js +0 -322
  121. package/bundle/node_modules/undici/lib/web/cookies/util.js +0 -282
  122. package/bundle/node_modules/undici/lib/web/eventsource/eventsource-stream.js +0 -399
  123. package/bundle/node_modules/undici/lib/web/eventsource/eventsource.js +0 -484
  124. package/bundle/node_modules/undici/lib/web/eventsource/util.js +0 -37
  125. package/bundle/node_modules/undici/lib/web/fetch/LICENSE +0 -21
  126. package/bundle/node_modules/undici/lib/web/fetch/body.js +0 -532
  127. package/bundle/node_modules/undici/lib/web/fetch/constants.js +0 -131
  128. package/bundle/node_modules/undici/lib/web/fetch/data-url.js +0 -744
  129. package/bundle/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +0 -46
  130. package/bundle/node_modules/undici/lib/web/fetch/formdata-parser.js +0 -501
  131. package/bundle/node_modules/undici/lib/web/fetch/formdata.js +0 -263
  132. package/bundle/node_modules/undici/lib/web/fetch/global.js +0 -40
  133. package/bundle/node_modules/undici/lib/web/fetch/headers.js +0 -719
  134. package/bundle/node_modules/undici/lib/web/fetch/index.js +0 -2258
  135. package/bundle/node_modules/undici/lib/web/fetch/request.js +0 -1099
  136. package/bundle/node_modules/undici/lib/web/fetch/response.js +0 -636
  137. package/bundle/node_modules/undici/lib/web/fetch/util.js +0 -1782
  138. package/bundle/node_modules/undici/lib/web/fetch/webidl.js +0 -740
  139. package/bundle/node_modules/undici/lib/web/websocket/connection.js +0 -325
  140. package/bundle/node_modules/undici/lib/web/websocket/constants.js +0 -126
  141. package/bundle/node_modules/undici/lib/web/websocket/events.js +0 -331
  142. package/bundle/node_modules/undici/lib/web/websocket/frame.js +0 -138
  143. package/bundle/node_modules/undici/lib/web/websocket/permessage-deflate.js +0 -70
  144. package/bundle/node_modules/undici/lib/web/websocket/receiver.js +0 -454
  145. package/bundle/node_modules/undici/lib/web/websocket/sender.js +0 -109
  146. package/bundle/node_modules/undici/lib/web/websocket/stream/websocketerror.js +0 -83
  147. package/bundle/node_modules/undici/lib/web/websocket/stream/websocketstream.js +0 -485
  148. package/bundle/node_modules/undici/lib/web/websocket/util.js +0 -338
  149. package/bundle/node_modules/undici/lib/web/websocket/websocket.js +0 -686
  150. package/bundle/node_modules/undici/package.json +0 -149
  151. package/bundle/node_modules/undici/scripts/strip-comments.js +0 -10
  152. package/bundle/node_modules/undici/types/README.md +0 -6
  153. package/bundle/node_modules/undici/types/agent.d.ts +0 -35
  154. package/bundle/node_modules/undici/types/api.d.ts +0 -43
  155. package/bundle/node_modules/undici/types/balanced-pool.d.ts +0 -29
  156. package/bundle/node_modules/undici/types/cache-interceptor.d.ts +0 -172
  157. package/bundle/node_modules/undici/types/cache.d.ts +0 -36
  158. package/bundle/node_modules/undici/types/client-stats.d.ts +0 -15
  159. package/bundle/node_modules/undici/types/client.d.ts +0 -110
  160. package/bundle/node_modules/undici/types/connector.d.ts +0 -34
  161. package/bundle/node_modules/undici/types/content-type.d.ts +0 -21
  162. package/bundle/node_modules/undici/types/cookies.d.ts +0 -30
  163. package/bundle/node_modules/undici/types/diagnostics-channel.d.ts +0 -66
  164. package/bundle/node_modules/undici/types/dispatcher.d.ts +0 -281
  165. package/bundle/node_modules/undici/types/env-http-proxy-agent.d.ts +0 -21
  166. package/bundle/node_modules/undici/types/errors.d.ts +0 -171
  167. package/bundle/node_modules/undici/types/eventsource.d.ts +0 -61
  168. package/bundle/node_modules/undici/types/fetch.d.ts +0 -210
  169. package/bundle/node_modules/undici/types/formdata.d.ts +0 -108
  170. package/bundle/node_modules/undici/types/global-dispatcher.d.ts +0 -9
  171. package/bundle/node_modules/undici/types/global-origin.d.ts +0 -7
  172. package/bundle/node_modules/undici/types/h2c-client.d.ts +0 -75
  173. package/bundle/node_modules/undici/types/handlers.d.ts +0 -15
  174. package/bundle/node_modules/undici/types/header.d.ts +0 -160
  175. package/bundle/node_modules/undici/types/index.d.ts +0 -75
  176. package/bundle/node_modules/undici/types/interceptors.d.ts +0 -34
  177. package/bundle/node_modules/undici/types/mock-agent.d.ts +0 -68
  178. package/bundle/node_modules/undici/types/mock-call-history.d.ts +0 -111
  179. package/bundle/node_modules/undici/types/mock-client.d.ts +0 -25
  180. package/bundle/node_modules/undici/types/mock-errors.d.ts +0 -12
  181. package/bundle/node_modules/undici/types/mock-interceptor.d.ts +0 -93
  182. package/bundle/node_modules/undici/types/mock-pool.d.ts +0 -25
  183. package/bundle/node_modules/undici/types/patch.d.ts +0 -29
  184. package/bundle/node_modules/undici/types/pool-stats.d.ts +0 -19
  185. package/bundle/node_modules/undici/types/pool.d.ts +0 -41
  186. package/bundle/node_modules/undici/types/proxy-agent.d.ts +0 -29
  187. package/bundle/node_modules/undici/types/readable.d.ts +0 -68
  188. package/bundle/node_modules/undici/types/retry-agent.d.ts +0 -8
  189. package/bundle/node_modules/undici/types/retry-handler.d.ts +0 -116
  190. package/bundle/node_modules/undici/types/util.d.ts +0 -18
  191. package/bundle/node_modules/undici/types/utility.d.ts +0 -7
  192. package/bundle/node_modules/undici/types/webidl.d.ts +0 -266
  193. package/bundle/node_modules/undici/types/websocket.d.ts +0 -184
@@ -1,227 +0,0 @@
1
- # Class: ProxyAgent
2
-
3
- Extends: `undici.Dispatcher`
4
-
5
- A Proxy Agent class that implements the Agent API. It allows the connection through proxy in a simple way.
6
-
7
- ## `new ProxyAgent([options])`
8
-
9
- Arguments:
10
-
11
- * **options** `ProxyAgentOptions` (required) - It extends the `Agent` options.
12
-
13
- Returns: `ProxyAgent`
14
-
15
- ### Parameter: `ProxyAgentOptions`
16
-
17
- Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
18
- > It ommits `AgentOptions#connect`.
19
-
20
- * **uri** `string | URL` (required) - The URI of the proxy server. This can be provided as a string, as an instance of the URL class, or as an object with a `uri` property of type string.
21
- If the `uri` is provided as a string or `uri` is an object with an `uri` property of type string, then it will be parsed into a `URL` object according to the [WHATWG URL Specification](https://url.spec.whatwg.org).
22
- For detailed information on the parsing process and potential validation errors, please refer to the ["Writing" section](https://url.spec.whatwg.org/#writing) of the WHATWG URL Specification.
23
- * **token** `string` (optional) - It can be passed by a string of token for authentication.
24
- * **auth** `string` (**deprecated**) - Use token.
25
- * **clientFactory** `(origin: URL, opts: Object) => Dispatcher` (optional) - Default: `(origin, opts) => new Pool(origin, opts)`
26
- * **requestTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
27
- * **proxyTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
28
- * **proxyTunnel** `boolean` (optional) - By default, ProxyAgent will request that the Proxy facilitate a tunnel between the endpoint and the agent. Setting `proxyTunnel` to false avoids issuing a CONNECT extension, and includes the endpoint domain and path in each request.
29
-
30
- Examples:
31
-
32
- ```js
33
- import { ProxyAgent } from 'undici'
34
-
35
- const proxyAgent = new ProxyAgent('my.proxy.server')
36
- // or
37
- const proxyAgent = new ProxyAgent(new URL('my.proxy.server'))
38
- // or
39
- const proxyAgent = new ProxyAgent({ uri: 'my.proxy.server' })
40
- // or
41
- const proxyAgent = new ProxyAgent({
42
- uri: new URL('my.proxy.server'),
43
- proxyTls: {
44
- signal: AbortSignal.timeout(1000)
45
- }
46
- })
47
- ```
48
-
49
- #### Example - Basic ProxyAgent instantiation
50
-
51
- This will instantiate the ProxyAgent. It will not do anything until registered as the agent to use with requests.
52
-
53
- ```js
54
- import { ProxyAgent } from 'undici'
55
-
56
- const proxyAgent = new ProxyAgent('my.proxy.server')
57
- ```
58
-
59
- #### Example - Basic Proxy Request with global agent dispatcher
60
-
61
- ```js
62
- import { setGlobalDispatcher, request, ProxyAgent } from 'undici'
63
-
64
- const proxyAgent = new ProxyAgent('my.proxy.server')
65
- setGlobalDispatcher(proxyAgent)
66
-
67
- const { statusCode, body } = await request('http://localhost:3000/foo')
68
-
69
- console.log('response received', statusCode) // response received 200
70
-
71
- for await (const data of body) {
72
- console.log('data', data.toString('utf8')) // data foo
73
- }
74
- ```
75
-
76
- #### Example - Basic Proxy Request with local agent dispatcher
77
-
78
- ```js
79
- import { ProxyAgent, request } from 'undici'
80
-
81
- const proxyAgent = new ProxyAgent('my.proxy.server')
82
-
83
- const {
84
- statusCode,
85
- body
86
- } = await request('http://localhost:3000/foo', { dispatcher: proxyAgent })
87
-
88
- console.log('response received', statusCode) // response received 200
89
-
90
- for await (const data of body) {
91
- console.log('data', data.toString('utf8')) // data foo
92
- }
93
- ```
94
-
95
- #### Example - Basic Proxy Request with authentication
96
-
97
- ```js
98
- import { setGlobalDispatcher, request, ProxyAgent } from 'undici';
99
-
100
- const proxyAgent = new ProxyAgent({
101
- uri: 'my.proxy.server',
102
- // token: 'Bearer xxxx'
103
- token: `Basic ${Buffer.from('username:password').toString('base64')}`
104
- });
105
- setGlobalDispatcher(proxyAgent);
106
-
107
- const { statusCode, body } = await request('http://localhost:3000/foo');
108
-
109
- console.log('response received', statusCode); // response received 200
110
-
111
- for await (const data of body) {
112
- console.log('data', data.toString('utf8')); // data foo
113
- }
114
- ```
115
-
116
- ### `ProxyAgent.close()`
117
-
118
- Closes the proxy agent and waits for registered pools and clients to also close before resolving.
119
-
120
- Returns: `Promise<void>`
121
-
122
- #### Example - clean up after tests are complete
123
-
124
- ```js
125
- import { ProxyAgent, setGlobalDispatcher } from 'undici'
126
-
127
- const proxyAgent = new ProxyAgent('my.proxy.server')
128
- setGlobalDispatcher(proxyAgent)
129
-
130
- await proxyAgent.close()
131
- ```
132
-
133
- ### `ProxyAgent.dispatch(options, handlers)`
134
-
135
- Implements [`Agent.dispatch(options, handlers)`](/docs/docs/api/Agent.md#parameter-agentdispatchoptions).
136
-
137
- ### `ProxyAgent.request(options[, callback])`
138
-
139
- See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
140
-
141
-
142
- #### Example - ProxyAgent with Fetch
143
-
144
- This example demonstrates how to use `fetch` with a proxy via `ProxyAgent`. It is particularly useful for scenarios requiring proxy tunneling.
145
-
146
- ```javascript
147
- import { ProxyAgent, fetch } from 'undici';
148
-
149
- // Define the ProxyAgent
150
- const proxyAgent = new ProxyAgent('http://localhost:8000');
151
-
152
- // Make a GET request through the proxy
153
- const response = await fetch('http://localhost:3000/foo', {
154
- dispatcher: proxyAgent,
155
- method: 'GET',
156
- });
157
-
158
- console.log('Response status:', response.status);
159
- console.log('Response data:', await response.text());
160
- ```
161
-
162
- ---
163
-
164
- #### Example - ProxyAgent with a Custom Proxy Server
165
-
166
- This example shows how to create a custom proxy server and use it with `ProxyAgent`.
167
-
168
- ```javascript
169
- import * as http from 'node:http';
170
- import { createProxy } from 'proxy';
171
- import { ProxyAgent, fetch } from 'undici';
172
-
173
- // Create a proxy server
174
- const proxyServer = createProxy(http.createServer());
175
- proxyServer.listen(8000, () => {
176
- console.log('Proxy server running on port 8000');
177
- });
178
-
179
- // Define and use the ProxyAgent
180
- const proxyAgent = new ProxyAgent('http://localhost:8000');
181
-
182
- const response = await fetch('http://example.com', {
183
- dispatcher: proxyAgent,
184
- method: 'GET',
185
- });
186
-
187
- console.log('Response status:', response.status);
188
- console.log('Response data:', await response.text());
189
- ```
190
-
191
- ---
192
-
193
- #### Example - ProxyAgent with HTTPS Tunneling
194
-
195
- This example demonstrates how to perform HTTPS tunneling using a proxy.
196
-
197
- ```javascript
198
- import { ProxyAgent, fetch } from 'undici';
199
-
200
- // Define a ProxyAgent for HTTPS proxy
201
- const proxyAgent = new ProxyAgent('https://secure.proxy.server');
202
-
203
- // Make a request to an HTTPS endpoint via the proxy
204
- const response = await fetch('https://secure.endpoint.com/api/data', {
205
- dispatcher: proxyAgent,
206
- method: 'GET',
207
- });
208
-
209
- console.log('Response status:', response.status);
210
- console.log('Response data:', await response.json());
211
- ```
212
-
213
- #### Example - ProxyAgent as a Global Dispatcher
214
-
215
- `ProxyAgent` can be configured as a global dispatcher, making it available for all requests without explicitly passing it. This simplifies code and is useful when a single proxy configuration applies to all requests.
216
-
217
- ```javascript
218
- import { ProxyAgent, setGlobalDispatcher, fetch } from 'undici';
219
-
220
- // Define and configure the ProxyAgent
221
- const proxyAgent = new ProxyAgent('http://localhost:8000');
222
- setGlobalDispatcher(proxyAgent);
223
-
224
- // Make requests without specifying the dispatcher
225
- const response = await fetch('http://example.com');
226
- console.log('Response status:', response.status);
227
- console.log('Response data:', await response.text());
@@ -1,96 +0,0 @@
1
- # Class: RedirectHandler
2
-
3
- A class that handles redirection logic for HTTP requests.
4
-
5
- ## `new RedirectHandler(dispatch, maxRedirections, opts, handler, redirectionLimitReached)`
6
-
7
- Arguments:
8
-
9
- - **dispatch** `function` - The dispatch function to be called after every retry.
10
- - **maxRedirections** `number` - Maximum number of redirections allowed.
11
- - **opts** `object` - Options for handling redirection.
12
- - **handler** `object` - An object containing handlers for different stages of the request lifecycle.
13
- - **redirectionLimitReached** `boolean` (default: `false`) - A flag that the implementer can provide to enable or disable the feature. If set to `false`, it indicates that the caller doesn't want to use the feature and prefers the old behavior.
14
-
15
- Returns: `RedirectHandler`
16
-
17
- ### Parameters
18
-
19
- - **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandler) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every redirection.
20
- - **maxRedirections** `number` (required) - Maximum number of redirections allowed.
21
- - **opts** `object` (required) - Options for handling redirection.
22
- - **handler** `object` (required) - Handlers for different stages of the request lifecycle.
23
- - **redirectionLimitReached** `boolean` (default: `false`) - A flag that the implementer can provide to enable or disable the feature. If set to `false`, it indicates that the caller doesn't want to use the feature and prefers the old behavior.
24
-
25
- ### Properties
26
-
27
- - **location** `string` - The current redirection location.
28
- - **abort** `function` - The abort function.
29
- - **opts** `object` - The options for handling redirection.
30
- - **maxRedirections** `number` - Maximum number of redirections allowed.
31
- - **handler** `object` - Handlers for different stages of the request lifecycle.
32
- - **history** `Array` - An array representing the history of URLs during redirection.
33
- - **redirectionLimitReached** `boolean` - Indicates whether the redirection limit has been reached.
34
-
35
- ### Methods
36
-
37
- #### `onConnect(abort)`
38
-
39
- Called when the connection is established.
40
-
41
- Parameters:
42
-
43
- - **abort** `function` - The abort function.
44
-
45
- #### `onUpgrade(statusCode, headers, socket)`
46
-
47
- Called when an upgrade is requested.
48
-
49
- Parameters:
50
-
51
- - **statusCode** `number` - The HTTP status code.
52
- - **headers** `object` - The headers received in the response.
53
- - **socket** `object` - The socket object.
54
-
55
- #### `onError(error)`
56
-
57
- Called when an error occurs.
58
-
59
- Parameters:
60
-
61
- - **error** `Error` - The error that occurred.
62
-
63
- #### `onHeaders(statusCode, headers, resume, statusText)`
64
-
65
- Called when headers are received.
66
-
67
- Parameters:
68
-
69
- - **statusCode** `number` - The HTTP status code.
70
- - **headers** `object` - The headers received in the response.
71
- - **resume** `function` - The resume function.
72
- - **statusText** `string` - The status text.
73
-
74
- #### `onData(chunk)`
75
-
76
- Called when data is received.
77
-
78
- Parameters:
79
-
80
- - **chunk** `Buffer` - The data chunk received.
81
-
82
- #### `onComplete(trailers)`
83
-
84
- Called when the request is complete.
85
-
86
- Parameters:
87
-
88
- - **trailers** `object` - The trailers received.
89
-
90
- #### `onBodySent(chunk)`
91
-
92
- Called when the request body is sent.
93
-
94
- Parameters:
95
-
96
- - **chunk** `Buffer` - The chunk of the request body sent.
@@ -1,45 +0,0 @@
1
- # Class: RetryAgent
2
-
3
- Extends: `undici.Dispatcher`
4
-
5
- A `undici.Dispatcher` that allows to automatically retry a request.
6
- Wraps a `undici.RetryHandler`.
7
-
8
- ## `new RetryAgent(dispatcher, [options])`
9
-
10
- Arguments:
11
-
12
- * **dispatcher** `undici.Dispatcher` (required) - the dispatcher to wrap
13
- * **options** `RetryHandlerOptions` (optional) - the options
14
-
15
- Returns: `ProxyAgent`
16
-
17
- ### Parameter: `RetryHandlerOptions`
18
-
19
- - **retry** `(err: Error, context: RetryContext, callback: (err?: Error | null) => void) => void` (optional) - Function to be called after every retry. It should pass error if no more retries should be performed.
20
- - **maxRetries** `number` (optional) - Maximum number of retries. Default: `5`
21
- - **maxTimeout** `number` (optional) - Maximum number of milliseconds to wait before retrying. Default: `30000` (30 seconds)
22
- - **minTimeout** `number` (optional) - Minimum number of milliseconds to wait before retrying. Default: `500` (half a second)
23
- - **timeoutFactor** `number` (optional) - Factor to multiply the timeout by for each retry attempt. Default: `2`
24
- - **retryAfter** `boolean` (optional) - It enables automatic retry after the `Retry-After` header is received. Default: `true`
25
- -
26
- - **methods** `string[]` (optional) - Array of HTTP methods to retry. Default: `['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE']`
27
- - **statusCodes** `number[]` (optional) - Array of HTTP status codes to retry. Default: `[429, 500, 502, 503, 504]`
28
- - **errorCodes** `string[]` (optional) - Array of Error codes to retry. Default: `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN','ENETUNREACH', 'EHOSTDOWN', 'UND_ERR_SOCKET']`
29
-
30
- **`RetryContext`**
31
-
32
- - `state`: `RetryState` - Current retry state. It can be mutated.
33
- - `opts`: `Dispatch.DispatchOptions & RetryOptions` - Options passed to the retry handler.
34
-
35
- Example:
36
-
37
- ```js
38
- import { Agent, RetryAgent } from 'undici'
39
-
40
- const agent = new RetryAgent(new Agent())
41
-
42
- const res = await agent.request('http://example.com')
43
- console.log(res.statusCode)
44
- console.log(await res.body.text())
45
- ```
@@ -1,117 +0,0 @@
1
- # Class: RetryHandler
2
-
3
- Extends: `undici.DispatcherHandlers`
4
-
5
- A handler class that implements the retry logic for a request.
6
-
7
- ## `new RetryHandler(dispatchOptions, retryHandlers, [retryOptions])`
8
-
9
- Arguments:
10
-
11
- - **options** `Dispatch.DispatchOptions & RetryOptions` (required) - It is an intersection of `Dispatcher.DispatchOptions` and `RetryOptions`.
12
- - **retryHandlers** `RetryHandlers` (required) - Object containing the `dispatch` to be used on every retry, and `handler` for handling the `dispatch` lifecycle.
13
-
14
- Returns: `retryHandler`
15
-
16
- ### Parameter: `Dispatch.DispatchOptions & RetryOptions`
17
-
18
- Extends: [`Dispatch.DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions).
19
-
20
- #### `RetryOptions`
21
-
22
- - **retry** `(err: Error, context: RetryContext, callback: (err?: Error | null) => void) => number | null` (optional) - Function to be called after every retry. It should pass error if no more retries should be performed.
23
- - **maxRetries** `number` (optional) - Maximum number of retries. Default: `5`
24
- - **maxTimeout** `number` (optional) - Maximum number of milliseconds to wait before retrying. Default: `30000` (30 seconds)
25
- - **minTimeout** `number` (optional) - Minimum number of milliseconds to wait before retrying. Default: `500` (half a second)
26
- - **timeoutFactor** `number` (optional) - Factor to multiply the timeout by for each retry attempt. Default: `2`
27
- - **retryAfter** `boolean` (optional) - It enables automatic retry after the `Retry-After` header is received. Default: `true`
28
- -
29
- - **methods** `string[]` (optional) - Array of HTTP methods to retry. Default: `['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE']`
30
- - **statusCodes** `number[]` (optional) - Array of HTTP status codes to retry. Default: `[429, 500, 502, 503, 504]`
31
- - **errorCodes** `string[]` (optional) - Array of Error codes to retry. Default: `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN','ENETUNREACH', 'EHOSTDOWN', 'UND_ERR_SOCKET']`
32
-
33
- **`RetryContext`**
34
-
35
- - `state`: `RetryState` - Current retry state. It can be mutated.
36
- - `opts`: `Dispatch.DispatchOptions & RetryOptions` - Options passed to the retry handler.
37
-
38
- **`RetryState`**
39
-
40
- It represents the retry state for a given request.
41
-
42
- - `counter`: `number` - Current retry attempt.
43
-
44
- ### Parameter `RetryHandlers`
45
-
46
- - **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandler) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every retry.
47
- - **handler** Extends [`Dispatch.DispatchHandler`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler) (required) - Handler function to be called after the request is successful or the retries are exhausted.
48
-
49
- >__Note__: The `RetryHandler` does not retry over stateful bodies (e.g. streams, AsyncIterable) as those, once consumed, are left in a state that cannot be reutilized. For these situations the `RetryHandler` will identify
50
- >the body as stateful and will not retry the request rejecting with the error `UND_ERR_REQ_RETRY`.
51
-
52
- Examples:
53
-
54
- ```js
55
- const client = new Client(`http://localhost:${server.address().port}`);
56
- const chunks = [];
57
- const handler = new RetryHandler(
58
- {
59
- ...dispatchOptions,
60
- retryOptions: {
61
- // custom retry function
62
- retry: function (err, state, callback) {
63
- counter++;
64
-
65
- if (err.code && err.code === "UND_ERR_DESTROYED") {
66
- callback(err);
67
- return;
68
- }
69
-
70
- if (err.statusCode === 206) {
71
- callback(err);
72
- return;
73
- }
74
-
75
- setTimeout(() => callback(null), 1000);
76
- },
77
- },
78
- },
79
- {
80
- dispatch: (...args) => {
81
- return client.dispatch(...args);
82
- },
83
- handler: {
84
- onConnect() {},
85
- onBodySent() {},
86
- onHeaders(status, _rawHeaders, resume, _statusMessage) {
87
- // do something with headers
88
- },
89
- onData(chunk) {
90
- chunks.push(chunk);
91
- return true;
92
- },
93
- onComplete() {},
94
- onError() {
95
- // handle error properly
96
- },
97
- },
98
- }
99
- );
100
- ```
101
-
102
- #### Example - Basic RetryHandler with defaults
103
-
104
- ```js
105
- const client = new Client(`http://localhost:${server.address().port}`);
106
- const handler = new RetryHandler(dispatchOptions, {
107
- dispatch: client.dispatch.bind(client),
108
- handler: {
109
- onConnect() {},
110
- onBodySent() {},
111
- onHeaders(status, _rawHeaders, resume, _statusMessage) {},
112
- onData(chunk) {},
113
- onComplete() {},
114
- onError(err) {},
115
- },
116
- });
117
- ```
@@ -1,25 +0,0 @@
1
- # Util
2
-
3
- Utility API for third-party implementations of the dispatcher API.
4
-
5
- ## `parseHeaders(headers, [obj])`
6
-
7
- Receives a header object and returns the parsed value.
8
-
9
- Arguments:
10
-
11
- - **headers** `(Buffer | string | (Buffer | string)[])[]` (required) - Header object.
12
-
13
- - **obj** `Record<string, string | string[]>` (optional) - Object to specify a proxy object. The parsed value is assigned to this object. But, if **headers** is an object, it is not used.
14
-
15
- Returns: `Record<string, string | string[]>` If **obj** is specified, it is equivalent to **obj**.
16
-
17
- ## `headerNameToString(value)`
18
-
19
- Retrieves a header name and returns its lowercase value.
20
-
21
- Arguments:
22
-
23
- - **value** `string | Buffer` (required) - Header name.
24
-
25
- Returns: `string`
@@ -1,85 +0,0 @@
1
- # Class: WebSocket
2
-
3
- Extends: [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
4
-
5
- The WebSocket object provides a way to manage a WebSocket connection to a server, allowing bidirectional communication. The API follows the [WebSocket spec](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) and [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455).
6
-
7
- ## `new WebSocket(url[, protocol])`
8
-
9
- Arguments:
10
-
11
- * **url** `URL | string`
12
- * **protocol** `string | string[] | WebSocketInit` (optional) - Subprotocol(s) to request the server use, or a [`Dispatcher`](/docs/docs/api/Dispatcher.md).
13
-
14
- ### Example:
15
-
16
- This example will not work in browsers or other platforms that don't allow passing an object.
17
-
18
- ```mjs
19
- import { WebSocket, ProxyAgent } from 'undici'
20
-
21
- const proxyAgent = new ProxyAgent('my.proxy.server')
22
-
23
- const ws = new WebSocket('wss://echo.websocket.events', {
24
- dispatcher: proxyAgent,
25
- protocols: ['echo', 'chat']
26
- })
27
- ```
28
-
29
- If you do not need a custom Dispatcher, it's recommended to use the following pattern:
30
-
31
- ```mjs
32
- import { WebSocket } from 'undici'
33
-
34
- const ws = new WebSocket('wss://echo.websocket.events', ['echo', 'chat'])
35
- ```
36
-
37
- # Class: WebSocketStream
38
-
39
- > ⚠️ Warning: the WebSocketStream API has not been finalized and is likely to change.
40
-
41
- See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocketStream) for more information.
42
-
43
- ## `new WebSocketStream(url[, protocol])`
44
-
45
- Arguments:
46
-
47
- * **url** `URL | string`
48
- * **options** `WebSocketStreamOptions` (optional)
49
-
50
- ### WebSocketStream Example
51
-
52
- ```js
53
- const stream = new WebSocketStream('https://echo.websocket.org/')
54
- const { readable, writable } = await stream.opened
55
-
56
- async function read () {
57
- /** @type {ReadableStreamReader} */
58
- const reader = readable.getReader()
59
-
60
- while (true) {
61
- const { done, value } = await reader.read()
62
- if (done) break
63
-
64
- // do something with value
65
- }
66
- }
67
-
68
- async function write () {
69
- /** @type {WritableStreamDefaultWriter} */
70
- const writer = writable.getWriter()
71
- writer.write('Hello, world!')
72
- writer.releaseLock()
73
- }
74
-
75
- read()
76
-
77
- setInterval(() => write(), 5000)
78
-
79
- ```
80
-
81
- ## Read More
82
-
83
- - [MDN - WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
84
- - [The WebSocket Specification](https://www.rfc-editor.org/rfc/rfc6455)
85
- - [The WHATWG WebSocket Specification](https://websockets.spec.whatwg.org/)