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,159 +0,0 @@
1
- # Class: EnvHttpProxyAgent
2
-
3
- Extends: `undici.Dispatcher`
4
-
5
- EnvHttpProxyAgent automatically reads the proxy configuration from the environment variables `http_proxy`, `https_proxy`, and `no_proxy` and sets up the proxy agents accordingly. When `http_proxy` and `https_proxy` are set, `http_proxy` is used for HTTP requests and `https_proxy` is used for HTTPS requests. If only `http_proxy` is set, `http_proxy` is used for both HTTP and HTTPS requests. If only `https_proxy` is set, it is only used for HTTPS requests.
6
-
7
- `no_proxy` is a comma or space-separated list of hostnames that should not be proxied. The list may contain leading wildcard characters (`*`). If `no_proxy` is set, the EnvHttpProxyAgent will bypass the proxy for requests to hosts that match the list. If `no_proxy` is set to `"*"`, the EnvHttpProxyAgent will bypass the proxy for all requests.
8
-
9
- Uppercase environment variables are also supported: `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`. However, if both the lowercase and uppercase environment variables are set, the uppercase environment variables will be ignored.
10
-
11
- ## `new EnvHttpProxyAgent([options])`
12
-
13
- Arguments:
14
-
15
- * **options** `EnvHttpProxyAgentOptions` (optional) - extends the `Agent` options.
16
-
17
- Returns: `EnvHttpProxyAgent`
18
-
19
- ### Parameter: `EnvHttpProxyAgentOptions`
20
-
21
- Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
22
-
23
- * **httpProxy** `string` (optional) - When set, it will override the `HTTP_PROXY` environment variable.
24
- * **httpsProxy** `string` (optional) - When set, it will override the `HTTPS_PROXY` environment variable.
25
- * **noProxy** `string` (optional) - When set, it will override the `NO_PROXY` environment variable.
26
-
27
- Examples:
28
-
29
- ```js
30
- import { EnvHttpProxyAgent } from 'undici'
31
-
32
- const envHttpProxyAgent = new EnvHttpProxyAgent()
33
- // or
34
- const envHttpProxyAgent = new EnvHttpProxyAgent({ httpProxy: 'my.proxy.server:8080', httpsProxy: 'my.proxy.server:8443', noProxy: 'localhost' })
35
- ```
36
-
37
- #### Example - EnvHttpProxyAgent instantiation
38
-
39
- This will instantiate the EnvHttpProxyAgent. It will not do anything until registered as the agent to use with requests.
40
-
41
- ```js
42
- import { EnvHttpProxyAgent } from 'undici'
43
-
44
- const envHttpProxyAgent = new EnvHttpProxyAgent()
45
- ```
46
-
47
- #### Example - Basic Proxy Fetch with global agent dispatcher
48
-
49
- ```js
50
- import { setGlobalDispatcher, fetch, EnvHttpProxyAgent } from 'undici'
51
-
52
- const envHttpProxyAgent = new EnvHttpProxyAgent()
53
- setGlobalDispatcher(envHttpProxyAgent)
54
-
55
- const { status, json } = await fetch('http://localhost:3000/foo')
56
-
57
- console.log('response received', status) // response received 200
58
-
59
- const data = await json() // data { foo: "bar" }
60
- ```
61
-
62
- #### Example - Basic Proxy Request with global agent dispatcher
63
-
64
- ```js
65
- import { setGlobalDispatcher, request, EnvHttpProxyAgent } from 'undici'
66
-
67
- const envHttpProxyAgent = new EnvHttpProxyAgent()
68
- setGlobalDispatcher(envHttpProxyAgent)
69
-
70
- const { statusCode, body } = await request('http://localhost:3000/foo')
71
-
72
- console.log('response received', statusCode) // response received 200
73
-
74
- for await (const data of body) {
75
- console.log('data', data.toString('utf8')) // data foo
76
- }
77
- ```
78
-
79
- #### Example - Basic Proxy Request with local agent dispatcher
80
-
81
- ```js
82
- import { EnvHttpProxyAgent, request } from 'undici'
83
-
84
- const envHttpProxyAgent = new EnvHttpProxyAgent()
85
-
86
- const {
87
- statusCode,
88
- body
89
- } = await request('http://localhost:3000/foo', { dispatcher: envHttpProxyAgent })
90
-
91
- console.log('response received', statusCode) // response received 200
92
-
93
- for await (const data of body) {
94
- console.log('data', data.toString('utf8')) // data foo
95
- }
96
- ```
97
-
98
- #### Example - Basic Proxy Fetch with local agent dispatcher
99
-
100
- ```js
101
- import { EnvHttpProxyAgent, fetch } from 'undici'
102
-
103
- const envHttpProxyAgent = new EnvHttpProxyAgent()
104
-
105
- const {
106
- status,
107
- json
108
- } = await fetch('http://localhost:3000/foo', { dispatcher: envHttpProxyAgent })
109
-
110
- console.log('response received', status) // response received 200
111
-
112
- const data = await json() // data { foo: "bar" }
113
- ```
114
-
115
- ## Instance Methods
116
-
117
- ### `EnvHttpProxyAgent.close([callback])`
118
-
119
- Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
120
-
121
- ### `EnvHttpProxyAgent.destroy([error, callback])`
122
-
123
- Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
124
-
125
- ### `EnvHttpProxyAgent.dispatch(options, handler: AgentDispatchOptions)`
126
-
127
- Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
128
-
129
- #### Parameter: `AgentDispatchOptions`
130
-
131
- Extends: [`DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions)
132
-
133
- * **origin** `string | URL`
134
-
135
- Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
136
-
137
- ### `EnvHttpProxyAgent.connect(options[, callback])`
138
-
139
- See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
140
-
141
- ### `EnvHttpProxyAgent.dispatch(options, handler)`
142
-
143
- Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
144
-
145
- ### `EnvHttpProxyAgent.pipeline(options, handler)`
146
-
147
- See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
148
-
149
- ### `EnvHttpProxyAgent.request(options[, callback])`
150
-
151
- See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
152
-
153
- ### `EnvHttpProxyAgent.stream(options, factory[, callback])`
154
-
155
- See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
156
-
157
- ### `EnvHttpProxyAgent.upgrade(options[, callback])`
158
-
159
- See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
@@ -1,49 +0,0 @@
1
- # Errors
2
-
3
- Undici exposes a variety of error objects that you can use to enhance your error handling.
4
- You can find all the error objects inside the `errors` key.
5
-
6
- ```js
7
- import { errors } from 'undici'
8
- ```
9
-
10
- | Error | Error Codes | Description |
11
- | ------------------------------------ | ------------------------------------- | ------------------------------------------------------------------------- |
12
- | `UndiciError` | `UND_ERR` | all errors below are extended from `UndiciError`. |
13
- | `ConnectTimeoutError` | `UND_ERR_CONNECT_TIMEOUT` | socket is destroyed due to connect timeout. |
14
- | `HeadersTimeoutError` | `UND_ERR_HEADERS_TIMEOUT` | socket is destroyed due to headers timeout. |
15
- | `HeadersOverflowError` | `UND_ERR_HEADERS_OVERFLOW` | socket is destroyed due to headers' max size being exceeded. |
16
- | `BodyTimeoutError` | `UND_ERR_BODY_TIMEOUT` | socket is destroyed due to body timeout. |
17
- | `ResponseStatusCodeError` | `UND_ERR_RESPONSE_STATUS_CODE` | an error is thrown when `throwOnError` is `true` for status codes >= 400. |
18
- | `InvalidArgumentError` | `UND_ERR_INVALID_ARG` | passed an invalid argument. |
19
- | `InvalidReturnValueError` | `UND_ERR_INVALID_RETURN_VALUE` | returned an invalid value. |
20
- | `RequestAbortedError` | `UND_ERR_ABORTED` | the request has been aborted by the user |
21
- | `ClientDestroyedError` | `UND_ERR_DESTROYED` | trying to use a destroyed client. |
22
- | `ClientClosedError` | `UND_ERR_CLOSED` | trying to use a closed client. |
23
- | `SocketError` | `UND_ERR_SOCKET` | there is an error with the socket. |
24
- | `NotSupportedError` | `UND_ERR_NOT_SUPPORTED` | encountered unsupported functionality. |
25
- | `RequestContentLengthMismatchError` | `UND_ERR_REQ_CONTENT_LENGTH_MISMATCH` | request body does not match content-length header |
26
- | `ResponseContentLengthMismatchError` | `UND_ERR_RES_CONTENT_LENGTH_MISMATCH` | response body does not match content-length header |
27
- | `InformationalError` | `UND_ERR_INFO` | expected error with reason |
28
- | `ResponseExceededMaxSizeError` | `UND_ERR_RES_EXCEEDED_MAX_SIZE` | response body exceed the max size allowed |
29
- | `SecureProxyConnectionError` | `UND_ERR_PRX_TLS` | tls connection to a proxy failed |
30
-
31
- Be aware of the possible difference between the global dispatcher version and the actual undici version you might be using. We recommend to avoid the check `instanceof errors.UndiciError` and seek for the `error.code === '<error_code>'` instead to avoid inconsistencies.
32
- ### `SocketError`
33
-
34
- The `SocketError` has a `.socket` property which holds socket metadata:
35
-
36
- ```ts
37
- interface SocketInfo {
38
- localAddress?: string
39
- localPort?: number
40
- remoteAddress?: string
41
- remotePort?: number
42
- remoteFamily?: string
43
- timeout?: number
44
- bytesWritten?: number
45
- bytesRead?: number
46
- }
47
- ```
48
-
49
- Be aware that in some cases the `.socket` property can be `null`.
@@ -1,45 +0,0 @@
1
- # EventSource
2
-
3
- > ⚠️ Warning: the EventSource API is experimental.
4
-
5
- Undici exposes a WHATWG spec-compliant implementation of [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)
6
- for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events).
7
-
8
- ## Instantiating EventSource
9
-
10
- Undici exports a EventSource class. You can instantiate the EventSource as
11
- follows:
12
-
13
- ```mjs
14
- import { EventSource } from 'undici'
15
-
16
- const eventSource = new EventSource('http://localhost:3000')
17
- eventSource.onmessage = (event) => {
18
- console.log(event.data)
19
- }
20
- ```
21
-
22
- ## Using a custom Dispatcher
23
-
24
- undici allows you to set your own Dispatcher in the EventSource constructor.
25
-
26
- An example which allows you to modify the request headers is:
27
-
28
- ```mjs
29
- import { EventSource, Agent } from 'undici'
30
-
31
- class CustomHeaderAgent extends Agent {
32
- dispatch (opts) {
33
- opts.headers['x-custom-header'] = 'hello world'
34
- return super.dispatch(...arguments)
35
- }
36
- }
37
-
38
- const eventSource = new EventSource('http://localhost:3000', {
39
- dispatcher: new CustomHeaderAgent()
40
- })
41
-
42
- ```
43
-
44
- More information about the EventSource API can be found on
45
- [MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventSource).
@@ -1,52 +0,0 @@
1
- # Fetch
2
-
3
- Undici exposes a fetch() method starts the process of fetching a resource from the network.
4
-
5
- Documentation and examples can be found on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
6
-
7
- ## FormData
8
-
9
- This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
10
-
11
- If any parameters are passed to the FormData constructor other than `undefined`, an error will be thrown. Other parameters are ignored.
12
-
13
- ## Response
14
-
15
- This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Response)
16
-
17
- ## Request
18
-
19
- This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Request)
20
-
21
- ## Header
22
-
23
- This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
24
-
25
- # Body Mixins
26
-
27
- `Response` and `Request` body inherit body mixin methods. These methods include:
28
-
29
- - [`.arrayBuffer()`](https://fetch.spec.whatwg.org/#dom-body-arraybuffer)
30
- - [`.blob()`](https://fetch.spec.whatwg.org/#dom-body-blob)
31
- - [`.bytes()`](https://fetch.spec.whatwg.org/#dom-body-bytes)
32
- - [`.formData()`](https://fetch.spec.whatwg.org/#dom-body-formdata)
33
- - [`.json()`](https://fetch.spec.whatwg.org/#dom-body-json)
34
- - [`.text()`](https://fetch.spec.whatwg.org/#dom-body-text)
35
-
36
- There is an ongoing discussion regarding `.formData()` and its usefulness and performance in server environments. It is recommended to use a dedicated library for parsing `multipart/form-data` bodies, such as [Busboy](https://www.npmjs.com/package/busboy) or [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy).
37
-
38
- These libraries can be interfaced with fetch with the following example code:
39
-
40
- ```mjs
41
- import { Busboy } from '@fastify/busboy'
42
- import { Readable } from 'node:stream'
43
-
44
- const response = await fetch('...')
45
- const busboy = new Busboy({
46
- headers: {
47
- 'content-type': response.headers.get('content-type')
48
- }
49
- })
50
-
51
- Readable.fromWeb(response.body).pipe(busboy)
52
- ```
@@ -1,262 +0,0 @@
1
- # Class: H2CClient
2
-
3
- Extends: `undici.Dispatcher`
4
-
5
- A basic H2C client.
6
-
7
- **Example**
8
-
9
- ```js
10
- const { createServer } = require('node:http2')
11
- const { once } = require('node:events')
12
- const { H2CClient } = require('undici')
13
-
14
- const server = createServer((req, res) => {
15
- res.writeHead(200)
16
- res.end('Hello, world!')
17
- })
18
-
19
- server.listen()
20
- once(server, 'listening').then(() => {
21
- const client = new H2CClient(`http://localhost:${server.address().port}/`)
22
-
23
- const response = await client.request({ path: '/', method: 'GET' })
24
- console.log(response.statusCode) // 200
25
- response.body.text.then((text) => {
26
- console.log(text) // Hello, world!
27
- })
28
- })
29
- ```
30
-
31
- ## `new H2CClient(url[, options])`
32
-
33
- Arguments:
34
-
35
- - **url** `URL | string` - Should only include the **protocol, hostname, and port**. It only supports `http` protocol.
36
- - **options** `H2CClientOptions` (optional)
37
-
38
- Returns: `H2CClient`
39
-
40
- ### Parameter: `H2CClientOptions`
41
-
42
- - **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. Please note the `timeout` will be reset if you keep writing data to the socket everytime.
43
- - **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds.
44
- - **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by _keep-alive_ hints from the server. Defaults to 10 minutes.
45
- - **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by _keep-alive_ hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds.
46
- - **keepAliveTimeoutThreshold** `number | null` (optional) - Default: `2e3` - A number of milliseconds subtracted from server _keep-alive_ hints when overriding `keepAliveTimeout` to account for timing inaccuracies caused by e.g. transport latency. Defaults to 2 seconds.
47
- - **maxHeaderSize** `number | null` (optional) - Default: `--max-http-header-size` or `16384` - The maximum length of request headers in bytes. Defaults to Node.js' --max-http-header-size or 16KiB.
48
- - **maxResponseSize** `number | null` (optional) - Default: `-1` - The maximum length of response body in bytes. Set to `-1` to disable.
49
- - **maxConcurrentStreams**: `number` - Default: `100`. Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
50
- - **pipelining** `number | null` (optional) - Default to `maxConcurrentStreams` - The amount of concurrent requests sent over a single HTTP/2 session in accordance with [RFC-7540](https://httpwg.org/specs/rfc7540.html#StreamsLayer) Stream specification. Streams can be closed up by remote server at any time.
51
- - **connect** `ConnectOptions | null` (optional) - Default: `null`.
52
- - **strictContentLength** `Boolean` (optional) - Default: `true` - Whether to treat request content length mismatches as errors. If true, an error is thrown when the request content-length header doesn't match the length of the request body.
53
- - **autoSelectFamily**: `boolean` (optional) - Default: depends on local Node version, on Node 18.13.0 and above is `false`. Enables a family autodetection algorithm that loosely implements section 5 of [RFC 8305](https://tools.ietf.org/html/rfc8305#section-5). See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details. This option is ignored if not supported by the current Node version.
54
- - **autoSelectFamilyAttemptTimeout**: `number` - Default: depends on local Node version, on Node 18.13.0 and above is `250`. The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details.
55
-
56
- #### Parameter: `H2CConnectOptions`
57
-
58
- - **socketPath** `string | null` (optional) - Default: `null` - An IPC endpoint, either Unix domain socket or Windows named pipe.
59
- - **timeout** `number | null` (optional) - In milliseconds, Default `10e3`.
60
- - **servername** `string | null` (optional)
61
- - **keepAlive** `boolean | null` (optional) - Default: `true` - TCP keep-alive enabled
62
- - **keepAliveInitialDelay** `number | null` (optional) - Default: `60000` - TCP keep-alive interval for the socket in milliseconds
63
-
64
- ### Example - Basic Client instantiation
65
-
66
- This will instantiate the undici H2CClient, but it will not connect to the origin until something is queued. Consider using `client.connect` to prematurely connect to the origin, or just call `client.request`.
67
-
68
- ```js
69
- "use strict";
70
- import { H2CClient } from "undici";
71
-
72
- const client = new H2CClient("http://localhost:3000");
73
- ```
74
-
75
- ## Instance Methods
76
-
77
- ### `H2CClient.close([callback])`
78
-
79
- Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
80
-
81
- ### `H2CClient.destroy([error, callback])`
82
-
83
- Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
84
-
85
- Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided).
86
-
87
- ### `H2CClient.connect(options[, callback])`
88
-
89
- See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
90
-
91
- ### `H2CClient.dispatch(options, handlers)`
92
-
93
- Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
94
-
95
- ### `H2CClient.pipeline(options, handler)`
96
-
97
- See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
98
-
99
- ### `H2CClient.request(options[, callback])`
100
-
101
- See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
102
-
103
- ### `H2CClient.stream(options, factory[, callback])`
104
-
105
- See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
106
-
107
- ### `H2CClient.upgrade(options[, callback])`
108
-
109
- See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
110
-
111
- ## Instance Properties
112
-
113
- ### `H2CClient.closed`
114
-
115
- - `boolean`
116
-
117
- `true` after `H2CClient.close()` has been called.
118
-
119
- ### `H2CClient.destroyed`
120
-
121
- - `boolean`
122
-
123
- `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed.
124
-
125
- ### `H2CClient.pipelining`
126
-
127
- - `number`
128
-
129
- Property to get and set the pipelining factor.
130
-
131
- ## Instance Events
132
-
133
- ### Event: `'connect'`
134
-
135
- See [Dispatcher Event: `'connect'`](/docs/docs/api/Dispatcher.md#event-connect).
136
-
137
- Parameters:
138
-
139
- - **origin** `URL`
140
- - **targets** `Array<Dispatcher>`
141
-
142
- Emitted when a socket has been created and connected. The client will connect once `client.size > 0`.
143
-
144
- #### Example - Client connect event
145
-
146
- ```js
147
- import { createServer } from "node:http2";
148
- import { H2CClient } from "undici";
149
- import { once } from "events";
150
-
151
- const server = createServer((request, response) => {
152
- response.end("Hello, World!");
153
- }).listen();
154
-
155
- await once(server, "listening");
156
-
157
- const client = new H2CClient(`http://localhost:${server.address().port}`);
158
-
159
- client.on("connect", (origin) => {
160
- console.log(`Connected to ${origin}`); // should print before the request body statement
161
- });
162
-
163
- try {
164
- const { body } = await client.request({
165
- path: "/",
166
- method: "GET",
167
- });
168
- body.setEncoding("utf-8");
169
- body.on("data", console.log);
170
- client.close();
171
- server.close();
172
- } catch (error) {
173
- console.error(error);
174
- client.close();
175
- server.close();
176
- }
177
- ```
178
-
179
- ### Event: `'disconnect'`
180
-
181
- See [Dispatcher Event: `'disconnect'`](/docs/docs/api/Dispatcher.md#event-disconnect).
182
-
183
- Parameters:
184
-
185
- - **origin** `URL`
186
- - **targets** `Array<Dispatcher>`
187
- - **error** `Error`
188
-
189
- Emitted when socket has disconnected. The error argument of the event is the error which caused the socket to disconnect. The client will reconnect if or once `client.size > 0`.
190
-
191
- #### Example - Client disconnect event
192
-
193
- ```js
194
- import { createServer } from "node:http2";
195
- import { H2CClient } from "undici";
196
- import { once } from "events";
197
-
198
- const server = createServer((request, response) => {
199
- response.destroy();
200
- }).listen();
201
-
202
- await once(server, "listening");
203
-
204
- const client = new H2CClient(`http://localhost:${server.address().port}`);
205
-
206
- client.on("disconnect", (origin) => {
207
- console.log(`Disconnected from ${origin}`);
208
- });
209
-
210
- try {
211
- await client.request({
212
- path: "/",
213
- method: "GET",
214
- });
215
- } catch (error) {
216
- console.error(error.message);
217
- client.close();
218
- server.close();
219
- }
220
- ```
221
-
222
- ### Event: `'drain'`
223
-
224
- Emitted when pipeline is no longer busy.
225
-
226
- See [Dispatcher Event: `'drain'`](/docs/docs/api/Dispatcher.md#event-drain).
227
-
228
- #### Example - Client drain event
229
-
230
- ```js
231
- import { createServer } from "node:http2";
232
- import { H2CClient } from "undici";
233
- import { once } from "events";
234
-
235
- const server = createServer((request, response) => {
236
- response.end("Hello, World!");
237
- }).listen();
238
-
239
- await once(server, "listening");
240
-
241
- const client = new H2CClient(`http://localhost:${server.address().port}`);
242
-
243
- client.on("drain", () => {
244
- console.log("drain event");
245
- client.close();
246
- server.close();
247
- });
248
-
249
- const requests = [
250
- client.request({ path: "/", method: "GET" }),
251
- client.request({ path: "/", method: "GET" }),
252
- client.request({ path: "/", method: "GET" }),
253
- ];
254
-
255
- await Promise.all(requests);
256
-
257
- console.log("requests completed");
258
- ```
259
-
260
- ### Event: `'error'`
261
-
262
- Invoked for users errors such as throwing in the `onError` handler.