@openclaw/slack 2026.10.10-beta.5 → 2026.11.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 (136) hide show
  1. package/dist/.setup/{account-configured-zcR9TJJN.mjs → account-configured-35y0-Hso.mjs} +1 -2
  2. package/dist/.setup/{account-inspect-CmkKiSb9.mjs → account-inspect-Bc7TVU8F.mjs} +3 -4
  3. package/dist/.setup/{accounts-msihSF3-.mjs → accounts-CEgdyqoW.mjs} +6 -10
  4. package/dist/.setup/{action-runtime-ChRfnnBu.mjs → action-runtime-DPoxYao5.mjs} +9 -10
  5. package/dist/.setup/action-runtime.runtime-DWKWaKgC.mjs +1 -0
  6. package/dist/.setup/{actions-By7tvpvv.mjs → actions-PF2cP6to.mjs} +14 -22
  7. package/dist/.setup/{approval-handler.runtime-D8ArtDQt.mjs → approval-handler.runtime-BtRklemy.mjs} +7 -8
  8. package/dist/.setup/{approval-message-updates-DT7XBPbV.mjs → approval-message-updates-CpwbsEj6.mjs} +2 -3
  9. package/dist/.setup/{channel-6YzXl_63.mjs → channel-BzPa5LRe.mjs} +32 -39
  10. package/dist/.setup/{channel-meta-C443t-lI.mjs → channel-meta-C5vsCo3a.mjs} +1 -2
  11. package/dist/.setup/{channel-type-BEFP2ORi.mjs → channel-type-Dh4vwh1Y.mjs} +5 -6
  12. package/dist/.setup/{channel.setup-u6QQdbTa.mjs → channel.setup-Cc6oaNPS.mjs} +10 -14
  13. package/dist/.setup/{config-schema-DNnh6bWU.mjs → config-schema-Cz3uId-c.mjs} +2 -4
  14. package/dist/.setup/{directory-config-Cjj0N8R0.mjs → directory-config-BEPra1E2.mjs} +5 -6
  15. package/dist/.setup/{directory-live-BIKD-5B_.mjs → directory-live-BkUwPrS0.mjs} +4 -5
  16. package/dist/.setup/{doctor-contract-Cd4-VzIM.mjs → doctor-contract-HK8aedwU.mjs} +7 -13
  17. package/dist/.setup/http-GpAVKwSX.mjs +2 -0
  18. package/dist/.setup/{message-tool-api-BS5ekEA_.mjs → message-tool-api-DeiQJoRV.mjs} +5 -7
  19. package/dist/.setup/{monitor-BFilOuM_.mjs → monitor-BSKi0nx-.mjs} +78 -137
  20. package/dist/.setup/{outbound-adapter-9dbnYtL1.mjs → outbound-adapter-C0R5jz6S.mjs} +8 -9
  21. package/dist/.setup/{pipeline.runtime-BG5swHnj.mjs → pipeline.runtime-zTQpztym.mjs} +41 -68
  22. package/dist/.setup/{plugin-routes-D4qozHVn.mjs → plugin-routes-lXsy_bNV.mjs} +2 -3
  23. package/dist/.setup/{policy-yhn48xf5.mjs → policy-Bp1FvE6m.mjs} +4 -6
  24. package/dist/.setup/{probe-IiHogLQN.mjs → probe-C5VWf3sz.mjs} +11 -19
  25. package/dist/.setup/{registry-DizWcnNp.mjs → registry-1G0f1zuZ.mjs} +2 -4
  26. package/dist/.setup/{relay-source-oY9SbDiX.mjs → relay-source-D1NGf3d2.mjs} +9 -5
  27. package/dist/.setup/{replies-CJwjTqDr.mjs → replies-BY9G1WZH.mjs} +7 -9
  28. package/dist/.setup/{reply-blocks-Ca-raz2z.mjs → reply-blocks-DOjiDr44.mjs} +4 -7
  29. package/dist/.setup/{resolve-channels-DRRhElwz.mjs → resolve-channels-BNQ1KZXh.mjs} +4 -5
  30. package/dist/.setup/{resolve-users-Cz8e17ky.mjs → resolve-users-C4dC8Z7D.mjs} +4 -5
  31. package/dist/.setup/{rolldown-runtime-B4FMCO8f.mjs → rolldown-runtime-nwUcYXjP.mjs} +1 -2
  32. package/dist/.setup/{runtime-JSVZSWAj.mjs → runtime-C6HKn7Av.mjs} +1 -2
  33. package/dist/.setup/runtime-setter-api-DrXr965r.mjs +2 -0
  34. package/dist/.setup/{scopes-DfQVi8Jw.mjs → scopes-C1aeCBa6.mjs} +2 -3
  35. package/dist/.setup/{secret-contract-B-Qm6aQQ.mjs → secret-contract-BH1ergYo.mjs} +3 -2
  36. package/dist/.setup/{secret-contract-api-DB6CMdgc.mjs → secret-contract-api-BdG3j9lT.mjs} +1 -1
  37. package/dist/.setup/{security-audit-DFGiFLqd.mjs → security-audit-C3hXCfDt.mjs} +2 -3
  38. package/dist/.setup/{send-C-8wY0lK.mjs → send-C5uXkmZV.mjs} +14 -21
  39. package/dist/.setup/{send-results-eeOu_HYm.mjs → send-results-D-o6PgtS.mjs} +1 -2
  40. package/dist/.setup/{session-status-Dv8wNBEt.mjs → session-status-CHkEn3HM.mjs} +31 -57
  41. package/dist/.setup/setup-plugin-api-9mACIIlc.mjs +2 -0
  42. package/dist/.setup/{setup-surface-9WVQgYCT.mjs → setup-surface-b9gluDhT.mjs} +7 -8
  43. package/dist/.setup/{shared-DpHCoKy2.mjs → shared-DbdvOUXo.mjs} +14 -18
  44. package/dist/.setup/{slash-dispatch.runtime-v5kQqJPh.mjs → slash-dispatch.runtime-Bf0r7kf2.mjs} +1 -1
  45. package/dist/.setup/{target-parsing-FFE26kOV.mjs → target-parsing-0pRZtahO.mjs} +1 -2
  46. package/dist/.setup/{targets-C6LZQL1Q.mjs → targets-BqXz7CpG.mjs} +2 -3
  47. package/dist/.setup/{thread-ts-Cvt7WD6B.mjs → thread-ts-47Au2-Yn.mjs} +1 -2
  48. package/dist/.source-module-urls/562d694877afe9d9dcbb3b32a8883c16974738f2aa892c48d45572cdc9a62529.json +1 -1
  49. package/dist/account-inspect-api.js +2 -3
  50. package/dist/api.js +17 -17
  51. package/dist/channel-config-api.js +1 -1
  52. package/dist/channel-entry.js +1 -2
  53. package/dist/channel-plugin-api.js +1 -1
  54. package/dist/configured-state.js +2 -3
  55. package/dist/directory-contract-api.js +1 -1
  56. package/dist/doctor-contract-api.js +1 -1
  57. package/dist/http-routes-api.js +1 -1
  58. package/dist/index.js +2 -3
  59. package/dist/message-tool-api.js +1 -1
  60. package/dist/runtime-api.js +12 -12
  61. package/dist/runtime-setter-api.js +1 -1
  62. package/dist/secret-contract-api.js +1 -1
  63. package/dist/security-contract-api.js +1 -1
  64. package/dist/setup-entry.js +4 -5
  65. package/dist/setup-plugin-api.js +1 -1
  66. package/node_modules/@slack/bolt/node_modules/body-parser/README.md +17 -13
  67. package/node_modules/@slack/bolt/node_modules/body-parser/lib/read.js +74 -57
  68. package/node_modules/@slack/bolt/node_modules/body-parser/lib/types/json.js +11 -11
  69. package/node_modules/@slack/bolt/node_modules/body-parser/lib/types/urlencoded.js +5 -5
  70. package/node_modules/@slack/bolt/node_modules/body-parser/lib/utils.js +0 -15
  71. package/node_modules/@slack/bolt/node_modules/body-parser/package.json +7 -12
  72. package/node_modules/undici/README.md +25 -3
  73. package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  74. package/node_modules/undici/docs/docs/api/Client.md +11 -6
  75. package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  76. package/node_modules/undici/docs/docs/api/Errors.md +76 -1
  77. package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  78. package/node_modules/undici/docs/docs/api/Interceptors.md +13 -6
  79. package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  80. package/node_modules/undici/docs/docs/index.md +12 -12
  81. package/node_modules/undici/docs/docs/type-map.json +66 -66
  82. package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  83. package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  84. package/node_modules/undici/lib/core/connect.js +10 -4
  85. package/node_modules/undici/lib/core/constants.js +12 -1
  86. package/node_modules/undici/lib/core/errors.js +38 -1
  87. package/node_modules/undici/lib/core/request.js +16 -1
  88. package/node_modules/undici/lib/core/symbols.js +2 -0
  89. package/node_modules/undici/lib/core/util.js +26 -1
  90. package/node_modules/undici/lib/dispatcher/agent.js +6 -2
  91. package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  92. package/node_modules/undici/lib/dispatcher/client-h2.js +46 -14
  93. package/node_modules/undici/lib/dispatcher/client.js +4 -1
  94. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  95. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  96. package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  97. package/node_modules/undici/lib/dispatcher/pool-base.js +65 -28
  98. package/node_modules/undici/lib/dispatcher/pool.js +11 -8
  99. package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  100. package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  101. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  102. package/node_modules/undici/lib/handler/cache-handler.js +153 -15
  103. package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  104. package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  105. package/node_modules/undici/lib/handler/retry-handler.js +44 -11
  106. package/node_modules/undici/lib/interceptor/cache.js +11 -3
  107. package/node_modules/undici/lib/interceptor/decompress.js +22 -9
  108. package/node_modules/undici/lib/interceptor/dns.js +11 -0
  109. package/node_modules/undici/lib/interceptor/response-error.js +72 -28
  110. package/node_modules/undici/lib/milo/LICENSE.md +7 -0
  111. package/node_modules/undici/lib/milo/no-simd.js +1002 -0
  112. package/node_modules/undici/lib/milo/simd.js +1002 -0
  113. package/node_modules/undici/lib/mock/mock-agent.js +11 -0
  114. package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  115. package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  116. package/node_modules/undici/lib/util/cache.js +11 -5
  117. package/node_modules/undici/lib/web/cookies/util.js +19 -2
  118. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  119. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  120. package/node_modules/undici/lib/web/fetch/body.js +47 -38
  121. package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  122. package/node_modules/undici/lib/web/fetch/headers.js +2 -2
  123. package/node_modules/undici/lib/web/fetch/index.js +8 -4
  124. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  125. package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  126. package/node_modules/undici/package.json +7 -5
  127. package/node_modules/undici/types/cache-interceptor.d.ts +10 -0
  128. package/node_modules/undici/types/client.d.ts +10 -4
  129. package/node_modules/undici/types/errors.d.ts +16 -1
  130. package/node_modules/undici/types/h2c-client.d.ts +1 -1
  131. package/node_modules/undici/types/interceptors.d.ts +6 -1
  132. package/package.json +5 -5
  133. package/dist/.setup/action-runtime.runtime-Ck_j1YTn.mjs +0 -1
  134. package/dist/.setup/http-C9sM-FXe.mjs +0 -2
  135. package/dist/.setup/runtime-setter-api-Cx_PV-xu.mjs +0 -2
  136. package/dist/.setup/setup-plugin-api-B18kDKtr.mjs +0 -2
@@ -0,0 +1,1064 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const util = require('../core/util.js')
5
+ const timers = require('../util/timers.js')
6
+ const {
7
+ HeadersTimeoutError,
8
+ HeadersOverflowError,
9
+ SocketError,
10
+ InformationalError,
11
+ BodyTimeoutError,
12
+ HTTPParserError,
13
+ ResponseContentLengthMismatchError,
14
+ ResponseExceededMaxSizeError
15
+ } = require('../core/errors.js')
16
+ const {
17
+ kUrl,
18
+ kReset,
19
+ kClient,
20
+ kParser,
21
+ kBlocking,
22
+ kRunning,
23
+ kWriting,
24
+ kQueue,
25
+ kKeepAliveDefaultTimeout,
26
+ kRunningIdx,
27
+ kError,
28
+ kPipelining,
29
+ kSocket,
30
+ kKeepAliveTimeoutValue,
31
+ kKeepAliveMaxTimeout,
32
+ kKeepAliveTimeoutThreshold,
33
+ kBodyTimeout,
34
+ kMaxResponseSize,
35
+ kResume,
36
+ kHTTPContext,
37
+ kMaxHeadersSize
38
+ } = require('../core/symbols.js')
39
+
40
+ const FastBuffer = Buffer[Symbol.species]
41
+ const removeAllListeners = util.removeAllListeners
42
+
43
+ const kPausedByHandler = Symbol('kPausedByHandler')
44
+
45
+ const BUFFER_PAGE_SIZE = 4096
46
+ const INITIAL_BUFFER_SIZE = 128 * 1024
47
+ const EMPTY_BUF = Buffer.alloc(0)
48
+ const BODY_KIND_CONTENT_LENGTH = 0
49
+ const EVENT_RANGE_SIZE = 9
50
+ const EVENT_HEADERS_SIZE = 19
51
+
52
+ let miloPackage
53
+
54
+ // We disable wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures.
55
+ let useWasmSIMD = process.arch !== 'ppc64'
56
+ // The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior.
57
+ if (process.env.UNDICI_NO_WASM_SIMD === '1') {
58
+ useWasmSIMD = false
59
+ } else if (process.env.UNDICI_NO_WASM_SIMD === '0') {
60
+ useWasmSIMD = true
61
+ }
62
+
63
+ const USE_NATIVE_TIMER = 0
64
+ const USE_FAST_TIMER = 1
65
+ const TIMEOUT_HEADERS = 2 | USE_FAST_TIMER
66
+ const TIMEOUT_BODY = 4 | USE_FAST_TIMER
67
+ const TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER
68
+
69
+ let miloEnabled =
70
+ process.env.UNDICI_USE_MILO === '1' || process.env.UNDICI_USE_MILO === 'true'
71
+ let miloInstance = null
72
+ let currentBuffer = null
73
+ let currentBufferSize = 0
74
+ let currentBufferPtr = null
75
+ let currentBufferRef = null
76
+
77
+ function onParserTimeout (parserWeakRef) {
78
+ const parser = parserWeakRef.deref ? parserWeakRef.deref() : parserWeakRef
79
+ if (!parser) {
80
+ return
81
+ }
82
+
83
+ const { socket, timeoutType, client, paused } = parser
84
+
85
+ if (timeoutType === TIMEOUT_HEADERS) {
86
+ if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
87
+ assert(!paused, 'cannot be paused while waiting for headers')
88
+ util.destroy(socket, new HeadersTimeoutError())
89
+ }
90
+ } else if (timeoutType === TIMEOUT_BODY) {
91
+ if (!paused) {
92
+ util.destroy(socket, new BodyTimeoutError())
93
+ }
94
+ } else if (timeoutType === TIMEOUT_KEEP_ALIVE) {
95
+ assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue])
96
+ util.destroy(socket, new InformationalError('socket idle timeout'))
97
+ }
98
+ }
99
+
100
+ function getMilo () {
101
+ if (miloInstance) {
102
+ return miloInstance
103
+ }
104
+
105
+ // Milo modules compile WASM on load; defer loading until the parser is needed.
106
+ if (useWasmSIMD) {
107
+ try {
108
+ miloPackage = require('../milo/simd.js')
109
+ } catch {}
110
+ }
111
+
112
+ miloPackage = miloPackage || require('../milo/no-simd.js')
113
+ miloInstance = miloPackage.setup()
114
+ return miloInstance
115
+ }
116
+
117
+ class H1Parser {
118
+ constructor (client, socket) {
119
+ this.milo = getMilo()
120
+
121
+ this.client = client
122
+ this.socket = socket
123
+ this.parser = this.milo.create()
124
+ this.events = new FastBuffer(
125
+ this.milo.memory.buffer,
126
+ this.parser + this.milo.ParserFields.EVENTS,
127
+ 4
128
+ ).readUInt32LE(0)
129
+
130
+ this.milo.setShouldAutodetect(this.parser, false)
131
+ this.milo.setIsRequest(this.parser, false)
132
+ this.milo.setShouldManageUnconsumed(this.parser, false)
133
+ this.milo.setShouldSuspendAfterHeaders(this.parser, true)
134
+ this.milo.setMaxHeaderLength(this.parser, client[kMaxHeadersSize])
135
+ this.milo.setActiveEvents(
136
+ this.parser,
137
+ this.milo.EVENT_ACTIVE_ON_ERROR |
138
+ this.milo.EVENT_ACTIVE_ON_MESSAGE_COMPLETE |
139
+ this.milo.EVENT_ACTIVE_ON_REASON |
140
+ this.milo.EVENT_ACTIVE_ON_HEADER_NAME |
141
+ this.milo.EVENT_ACTIVE_ON_HEADER_VALUE |
142
+ this.milo.EVENT_ACTIVE_ON_HEADERS |
143
+ this.milo.EVENT_ACTIVE_ON_DATA |
144
+ this.milo.EVENT_ACTIVE_ON_TRAILER_NAME |
145
+ this.milo.EVENT_ACTIVE_ON_TRAILER_VALUE
146
+ )
147
+
148
+ this.timeout = null
149
+ this.timeoutWeakRef = new WeakRef(this)
150
+ this.timeoutValue = null
151
+ this.timeoutType = null
152
+ this.statusCode = 0
153
+ this.statusText = ''
154
+ this.upgrade = false
155
+ this.responseStarted = false
156
+ this.pausedByParser = false
157
+ this.pauseStateIsStart = false
158
+ this.headers = []
159
+ this.trailers = []
160
+ this.headersSize = 0
161
+ this.trailersSize = 0
162
+ this.headersMaxSize = client[kMaxHeadersSize]
163
+ this.shouldKeepAlive = false
164
+ this.paused = false
165
+ this.errored = false
166
+ this.waitingForMoreData = 0
167
+ this.resume = this.resume.bind(this)
168
+ this.bytesRead = 0
169
+ this.keepAlive = ''
170
+ this.connection = ''
171
+ this.contentLength = -1
172
+ this.maxResponseSize = client[kMaxResponseSize]
173
+ this.directBodyRemaining = 0
174
+ this.directBodyCompletePending = false
175
+ this.headersSuspended = false
176
+ this.skipBody = false
177
+
178
+ this[kPausedByHandler] = false
179
+
180
+ if (
181
+ INITIAL_BUFFER_SIZE > currentBufferSize ||
182
+ currentBuffer.buffer !== this.milo.memory.buffer
183
+ ) {
184
+ this.ensureBuffers(INITIAL_BUFFER_SIZE)
185
+ } else {
186
+ this.updateBuffers()
187
+ }
188
+ }
189
+
190
+ setTimeout (delay, type) {
191
+ if (
192
+ delay !== this.timeoutValue ||
193
+ (type & USE_FAST_TIMER) ^ (this.timeoutType & USE_FAST_TIMER)
194
+ ) {
195
+ if (this.timeout) {
196
+ timers.clearTimeout(this.timeout)
197
+ this.timeout = null
198
+ }
199
+
200
+ if (delay) {
201
+ if (type & USE_FAST_TIMER) {
202
+ this.timeout = timers.setFastTimeout(
203
+ onParserTimeout,
204
+ delay,
205
+ this.timeoutWeakRef
206
+ )
207
+ } else {
208
+ this.timeout = setTimeout(
209
+ onParserTimeout,
210
+ delay,
211
+ this.timeoutWeakRef
212
+ )
213
+ this.timeout?.unref()
214
+ }
215
+ }
216
+
217
+ this.timeoutValue = delay
218
+ } else if (this.timeout?.refresh) {
219
+ this.timeout.refresh()
220
+ }
221
+
222
+ this.timeoutType = type
223
+ }
224
+
225
+ ensureBuffers (size) {
226
+ const { milo } = this
227
+
228
+ if (currentBufferPtr != null) {
229
+ milo.dealloc(currentBufferPtr, currentBufferSize)
230
+ }
231
+
232
+ // Reallocate buffers
233
+ currentBufferSize = Math.ceil(size / BUFFER_PAGE_SIZE) * BUFFER_PAGE_SIZE
234
+ currentBufferPtr = milo.alloc(currentBufferSize)
235
+ currentBuffer = new FastBuffer(
236
+ milo.memory.buffer,
237
+ currentBufferPtr,
238
+ currentBufferSize
239
+ )
240
+
241
+ this.updateBuffers()
242
+ }
243
+
244
+ updateBuffers () {
245
+ this.parserFields = new FastBuffer(this.milo.memory.buffer, this.parser)
246
+ this.parserEvents = new FastBuffer(
247
+ this.milo.memory.buffer,
248
+ this.events,
249
+ 64 * 1024
250
+ )
251
+ }
252
+
253
+ resume () {
254
+ if (this.socket.destroyed || !this.paused) {
255
+ return
256
+ }
257
+
258
+ this.milo.resume(this.parser)
259
+
260
+ assert(this.timeoutType === TIMEOUT_BODY)
261
+ if (this.timeout?.refresh) {
262
+ this.timeout.refresh()
263
+ }
264
+
265
+ this.paused = false
266
+ if (this.directBodyCompletePending) {
267
+ try {
268
+ this.completeDirectBody()
269
+ } catch (err) {
270
+ util.destroy(this.socket, err)
271
+ return
272
+ }
273
+
274
+ if (this.paused) {
275
+ return
276
+ }
277
+ }
278
+
279
+ this.readMore()
280
+ }
281
+
282
+ readMore () {
283
+ if (this.paused || !this.parser) {
284
+ return
285
+ }
286
+
287
+ while (!this.paused && this.parser) {
288
+ if (
289
+ this.waitingForMoreData &&
290
+ this.socket.readableLength <= this.waitingForMoreData
291
+ ) {
292
+ break
293
+ }
294
+
295
+ this.waitingForMoreData = 0
296
+
297
+ const chunk = this.socket.read()
298
+ if (chunk === null) {
299
+ break
300
+ }
301
+
302
+ if (this.execute(chunk) === false) {
303
+ break
304
+ }
305
+ }
306
+ }
307
+
308
+ execute (data) {
309
+ const available = data.length
310
+ assert(!this.paused)
311
+
312
+ const { socket, milo } = this
313
+
314
+ try {
315
+ if (this.directBodyRemaining > 0) {
316
+ return this.consumeDirectBody(data)
317
+ }
318
+
319
+ if (currentBuffer.buffer !== milo.memory.buffer) {
320
+ currentBuffer = new FastBuffer(
321
+ milo.memory.buffer,
322
+ currentBufferPtr,
323
+ currentBufferSize
324
+ )
325
+ this.updateBuffers()
326
+ } else if (this.parserEvents.buffer !== milo.memory.buffer) {
327
+ this.updateBuffers()
328
+ }
329
+
330
+ let offset = 0
331
+ let parseLen = available
332
+ const headersEnd = this.statusCode === 0 ? data.indexOf('\r\n\r\n') : -1
333
+
334
+ if (headersEnd !== -1) {
335
+ parseLen = headersEnd + 4
336
+ }
337
+
338
+ for (;;) {
339
+ if (parseLen > currentBufferSize) {
340
+ this.ensureBuffers(parseLen)
341
+ }
342
+
343
+ const parseData = data.subarray(offset, offset + parseLen)
344
+ currentBuffer.set(parseData)
345
+ currentBufferRef = parseData
346
+
347
+ const consumed = milo.parse(this.parser, currentBufferPtr, parseLen)
348
+ this.drainEvents()
349
+
350
+ const consumedTotal = offset + consumed
351
+
352
+ if (
353
+ this.errored ||
354
+ (consumed === 0 &&
355
+ this.parserFields[milo.ParserFields.ERROR_CODE] !== milo.ERROR_NONE)
356
+ ) {
357
+ throw this.createError(data.subarray(consumedTotal))
358
+ } else if (this.upgrade) {
359
+ this.onUpgrade(data.subarray(consumedTotal))
360
+ return false
361
+ } else if (this.directBodyCompletePending) {
362
+ this.completeDirectBody()
363
+
364
+ if (this.paused) {
365
+ return false
366
+ }
367
+ } else if (this.pausedByParser) {
368
+ this.pausedByParser = false
369
+ this.headersSuspended = false
370
+ if (this[kPausedByHandler] && this.pauseStateIsStart) {
371
+ this.pauseStateIsStart = false
372
+ milo.resume(this.parser)
373
+ this[kPausedByHandler] = false
374
+ return false
375
+ }
376
+
377
+ this.pauseStateIsStart = false
378
+ this.paused = true
379
+ socket.unshift(data.subarray(consumedTotal))
380
+ return false
381
+ }
382
+
383
+ if (this.directBodyRemaining > 0) {
384
+ return this.consumeDirectBody(data.subarray(consumedTotal))
385
+ }
386
+
387
+ if (consumed < parseLen) {
388
+ const remaining = data.subarray(consumedTotal)
389
+ socket.unshift(remaining)
390
+ this.waitingForMoreData = consumed === 0 ? remaining.length : 0
391
+ return false
392
+ }
393
+
394
+ offset = consumedTotal
395
+
396
+ if (offset >= available) {
397
+ if (this.headersSuspended) {
398
+ this.headersSuspended = false
399
+ parseLen = 0
400
+ continue
401
+ }
402
+
403
+ return true
404
+ }
405
+
406
+ this.headersSuspended = false
407
+ parseLen = available - offset
408
+ }
409
+ } catch (err) {
410
+ util.destroy(socket, err)
411
+ return false
412
+ } finally {
413
+ currentBufferRef = null
414
+ }
415
+ }
416
+
417
+ consumeDirectBody (data) {
418
+ const { socket, client, maxResponseSize } = this
419
+ const available = data.length
420
+ const len = Math.min(available, this.directBodyRemaining)
421
+
422
+ if (this.timeout?.refresh) {
423
+ this.timeout.refresh()
424
+ }
425
+
426
+ if (len > 0) {
427
+ const request = client[kQueue][client[kRunningIdx]]
428
+ assert(request)
429
+ assert(this.timeoutType === TIMEOUT_BODY)
430
+ assert(this.statusCode >= 200)
431
+
432
+ if (maxResponseSize > -1 && this.bytesRead + len > maxResponseSize) {
433
+ throw new ResponseExceededMaxSizeError()
434
+ }
435
+
436
+ this.bytesRead += len
437
+ this.directBodyRemaining -= len
438
+
439
+ if (request.onResponseData(data.subarray(0, len)) === false) {
440
+ this.directBodyCompletePending = this.directBodyRemaining === 0
441
+ this.pauseParser()
442
+ this[kPausedByHandler] = true
443
+ this.pausedByParser = false
444
+ this.paused = true
445
+
446
+ if (len < available) {
447
+ socket.unshift(data.subarray(len))
448
+ }
449
+
450
+ return false
451
+ }
452
+ }
453
+
454
+ if (this.directBodyRemaining === 0) {
455
+ this.completeDirectBody()
456
+
457
+ const remaining = data.subarray(len)
458
+ if (
459
+ this.errored ||
460
+ this.parserFields[this.milo.ParserFields.ERROR_CODE] !==
461
+ this.milo.ERROR_NONE
462
+ ) {
463
+ throw this.createError(remaining)
464
+ } else if (this.pausedByParser) {
465
+ this.pausedByParser = false
466
+ this.pauseStateIsStart = false
467
+ this.paused = true
468
+ if (remaining.length > 0) {
469
+ socket.unshift(remaining)
470
+ }
471
+ return false
472
+ }
473
+
474
+ if (remaining.length > 0) {
475
+ socket.unshift(remaining)
476
+ return false
477
+ }
478
+ }
479
+
480
+ return true
481
+ }
482
+
483
+ completeDirectBody () {
484
+ const { milo } = this
485
+
486
+ if (currentBuffer.buffer !== milo.memory.buffer) {
487
+ currentBuffer = new FastBuffer(
488
+ milo.memory.buffer,
489
+ currentBufferPtr,
490
+ currentBufferSize
491
+ )
492
+ this.updateBuffers()
493
+ } else if (this.parserEvents.buffer !== milo.memory.buffer) {
494
+ this.updateBuffers()
495
+ }
496
+
497
+ this.directBodyCompletePending = false
498
+ currentBufferRef = EMPTY_BUF
499
+
500
+ milo.complete(this.parser)
501
+ this.drainEvents()
502
+ }
503
+
504
+ setShouldSkipBody (value) {
505
+ if (this.skipBody !== value) {
506
+ this.skipBody = value
507
+ this.milo.setShouldSkipBody(this.parser, value)
508
+ }
509
+ }
510
+
511
+ finish () {
512
+ if (!this.parser) {
513
+ return null
514
+ }
515
+
516
+ if (this.directBodyRemaining > 0) {
517
+ return new ResponseContentLengthMismatchError()
518
+ }
519
+
520
+ if (this.parserEvents.buffer !== this.milo.memory.buffer) {
521
+ this.updateBuffers()
522
+ }
523
+
524
+ this.milo.finish(this.parser)
525
+ this.drainEvents()
526
+
527
+ if (!this.errored) {
528
+ return null
529
+ }
530
+
531
+ return this.createError(EMPTY_BUF)
532
+ }
533
+
534
+ createError (data) {
535
+ const { contentLength, bytesRead } = this
536
+
537
+ if (contentLength !== -1 && bytesRead !== contentLength) {
538
+ return new ResponseContentLengthMismatchError()
539
+ }
540
+
541
+ const errorCode = this.parserFields[this.milo.ParserFields.ERROR_CODE]
542
+ const errorName = this.milo.Errors[errorCode]
543
+ const errorDescription =
544
+ errorName === 'UNEXPECTED_EOF'
545
+ ? 'Invalid EOF state'
546
+ : this.milo.getErrorDescription(this.parser)
547
+ const reason =
548
+ errorName === 'UNEXPECTED_EOF'
549
+ ? errorDescription
550
+ : errorDescription
551
+ ? `[ERROR_${errorName}] ${errorDescription}`
552
+ : `ERROR_${errorName}`
553
+ return new HTTPParserError(
554
+ `Response does not match the HTTP/1.1 protocol (${reason})`,
555
+ errorName,
556
+ data
557
+ )
558
+ }
559
+
560
+ destroy () {
561
+ if (this.parser) {
562
+ this.milo.destroy(this.parser)
563
+ this.parser = null
564
+ }
565
+
566
+ this.timeout && timers.clearTimeout(this.timeout)
567
+ this.timeout = null
568
+ this.timeoutValue = null
569
+ this.timeoutType = null
570
+ this.paused = false
571
+ this.responseStarted = false
572
+ this.pausedByParser = false
573
+ this.pauseStateIsStart = false
574
+ this.connection = ''
575
+ this.skipBody = false
576
+ }
577
+
578
+ pauseParser (stateIsStart = false) {
579
+ this.milo.pause(this.parser)
580
+ this.pausedByParser = true
581
+ this.pauseStateIsStart = stateIsStart
582
+ }
583
+
584
+ drainEvents () {
585
+ const { socket, client, milo } = this
586
+ let cursor = 0
587
+
588
+ const firstEvent = this.parserEvents[0]
589
+ if (
590
+ firstEvent !== milo.EVENT_END &&
591
+ firstEvent !== milo.EVENT_ERROR &&
592
+ !this.responseStarted
593
+ ) {
594
+ this.responseStarted = true
595
+
596
+ if (socket.destroyed) {
597
+ return this.fail(this.milo.ERROR_CALLBACK_ERROR, 'Other side closed')
598
+ }
599
+
600
+ const request = client[kQueue][client[kRunningIdx]]
601
+ if (!request) {
602
+ return this.fail(this.milo.ERROR_CALLBACK_ERROR, 'Missing request')
603
+ }
604
+
605
+ request.onResponseStarted()
606
+ }
607
+
608
+ for (;;) {
609
+ const event = this.parserEvents[cursor]
610
+ let eventLen = EVENT_RANGE_SIZE
611
+ switch (event) {
612
+ case milo.EVENT_END:
613
+ return
614
+ case milo.EVENT_ERROR:
615
+ this.errored = true
616
+ return
617
+ case milo.EVENT_MESSAGE_COMPLETE: {
618
+ const {
619
+ client,
620
+ socket,
621
+ statusCode,
622
+ upgrade,
623
+ trailers,
624
+ contentLength,
625
+ bytesRead,
626
+ shouldKeepAlive
627
+ } = this
628
+
629
+ this.responseStarted = false
630
+
631
+ if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
632
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Other side closed')
633
+ }
634
+
635
+ if (upgrade) {
636
+ this.pauseParser()
637
+ return
638
+ }
639
+
640
+ assert(statusCode >= 100)
641
+
642
+ const request = client[kQueue][client[kRunningIdx]]
643
+ assert(request)
644
+
645
+ this.statusCode = 0
646
+ this.statusText = ''
647
+ this.bytesRead = 0
648
+ this.contentLength = -1
649
+ this.directBodyRemaining = 0
650
+ this.directBodyCompletePending = false
651
+ this.headersSuspended = false
652
+ this.skipBody = false
653
+ this.keepAlive = ''
654
+ this.connection = ''
655
+ this.trailers = []
656
+ this.trailersSize = 0
657
+
658
+ if (statusCode < 200) {
659
+ break
660
+ }
661
+
662
+ if (
663
+ request.method !== 'HEAD' &&
664
+ contentLength !== -1 &&
665
+ bytesRead !== contentLength
666
+ ) {
667
+ util.destroy(socket, new ResponseContentLengthMismatchError())
668
+ this.pauseParser()
669
+ break
670
+ }
671
+
672
+ request.onResponseEnd(trailers)
673
+
674
+ client[kQueue][client[kRunningIdx]++] = null
675
+
676
+ if (socket[kWriting]) {
677
+ assert(client[kRunning] === 0)
678
+ util.destroy(socket, new InformationalError('reset'))
679
+ this.pauseParser(true)
680
+ } else if (!shouldKeepAlive) {
681
+ util.destroy(socket, new InformationalError('reset'))
682
+ this.pauseParser(true)
683
+ } else if (socket[kReset] && client[kRunning] === 0) {
684
+ util.destroy(socket, new InformationalError('reset'))
685
+ this.pauseParser(true)
686
+ } else if (client[kPipelining] == null || client[kPipelining] === 1) {
687
+ setImmediate(client[kResume])
688
+ } else {
689
+ client[kResume]()
690
+ }
691
+
692
+ break
693
+ }
694
+ case milo.EVENT_REASON: {
695
+ const at = this.parserEvents.readUInt32LE(cursor + 1)
696
+ const len = this.parserEvents.readUInt32LE(cursor + 5)
697
+ this.statusText = new FastBuffer(
698
+ currentBufferRef.buffer,
699
+ currentBufferRef.byteOffset + at,
700
+ len
701
+ ).toString()
702
+ break
703
+ }
704
+ case milo.EVENT_HEADER_NAME: {
705
+ const at = this.parserEvents.readUInt32LE(cursor + 1)
706
+ const len = this.parserEvents.readUInt32LE(cursor + 5)
707
+ const data =
708
+ len > 0
709
+ ? new FastBuffer(
710
+ currentBufferRef.buffer,
711
+ currentBufferRef.byteOffset + at,
712
+ len
713
+ )
714
+ : EMPTY_BUF
715
+
716
+ this.headers.push(data)
717
+ this.headersSize += len
718
+ if (this.headersSize >= this.headersMaxSize) {
719
+ util.destroy(this.socket, new HeadersOverflowError())
720
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Headers overflow')
721
+ }
722
+
723
+ break
724
+ }
725
+ case milo.EVENT_HEADER_VALUE: {
726
+ const at = this.parserEvents.readUInt32LE(cursor + 1)
727
+ const len = this.parserEvents.readUInt32LE(cursor + 5)
728
+ const data =
729
+ len > 0
730
+ ? new FastBuffer(
731
+ currentBufferRef.buffer,
732
+ currentBufferRef.byteOffset + at,
733
+ len
734
+ )
735
+ : EMPTY_BUF
736
+ const key = this.headers[this.headers.length - 1]
737
+
738
+ this.headers.push(data)
739
+
740
+ if (key.length === 10) {
741
+ const headerName = util.bufferToLowerCasedHeaderName(key)
742
+ if (headerName === 'keep-alive') {
743
+ this.keepAlive += (this.keepAlive.length === 0 ? '' : ',') + data.toString()
744
+ } else if (headerName === 'connection') {
745
+ this.connection += (this.connection.length === 0 ? '' : ',') + data.toString()
746
+ }
747
+ }
748
+
749
+ this.headersSize += len
750
+ if (this.headersSize >= this.headersMaxSize) {
751
+ util.destroy(this.socket, new HeadersOverflowError())
752
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Headers overflow')
753
+ }
754
+
755
+ break
756
+ }
757
+ case milo.EVENT_HEADERS: {
758
+ eventLen = EVENT_HEADERS_SIZE
759
+
760
+ const statusCode = this.parserEvents.readUInt16LE(cursor + 5)
761
+ const shouldKeepAlive = this.parserEvents[cursor + 7] !== 0
762
+ const shouldUpgrade = this.parserEvents[cursor + 8] !== 0
763
+ const hasTrailers = this.parserEvents[cursor + 9] !== 0
764
+ const bodyKind = this.parserEvents[cursor + 10]
765
+ const contentLength =
766
+ this.parserEvents.readUInt32LE(cursor + 11) +
767
+ this.parserEvents.readUInt32LE(cursor + 15) * 0x100000000
768
+
769
+ const { socket, client, headers, statusText } = this
770
+
771
+ if (socket.destroyed) {
772
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Other side closed')
773
+ }
774
+
775
+ const request = client[kQueue][client[kRunningIdx]]
776
+ if (!request) {
777
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Missing request')
778
+ }
779
+
780
+ assert(!this.upgrade)
781
+ assert(this.statusCode < 200)
782
+
783
+ if (statusCode === 100) {
784
+ util.destroy(
785
+ socket,
786
+ new SocketError('bad response', util.getSocketInfo(socket))
787
+ )
788
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Bad response')
789
+ }
790
+
791
+ if (shouldUpgrade && !request.upgrade) {
792
+ util.destroy(
793
+ socket,
794
+ new SocketError('bad upgrade', util.getSocketInfo(socket))
795
+ )
796
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Bad upgrade')
797
+ }
798
+
799
+ assert(this.timeoutType === TIMEOUT_HEADERS)
800
+
801
+ this.statusCode = statusCode
802
+ this.shouldKeepAlive =
803
+ shouldKeepAlive ||
804
+ (request.method === 'HEAD' &&
805
+ !socket[kReset] &&
806
+ /(?:^|,)[\t ]*keep-alive[\t ]*(?:,|$)/i.test(this.connection) &&
807
+ !/(?:^|,)[\t ]*close[\t ]*(?:,|$)/i.test(this.connection))
808
+ this.contentLength =
809
+ bodyKind === BODY_KIND_CONTENT_LENGTH ? contentLength : -1
810
+
811
+ if (this.statusCode >= 200) {
812
+ const bodyTimeout =
813
+ request.bodyTimeout != null
814
+ ? request.bodyTimeout
815
+ : client[kBodyTimeout]
816
+ this.setTimeout(bodyTimeout, TIMEOUT_BODY)
817
+ } else if (this.timeout?.refresh) {
818
+ this.timeout.refresh()
819
+ }
820
+
821
+ if (request.method === 'CONNECT') {
822
+ assert(client[kRunning] === 1)
823
+ milo.setIsConnect(this.parser, true)
824
+ this.upgrade = true
825
+ return
826
+ }
827
+
828
+ if (shouldUpgrade) {
829
+ assert(client[kRunning] === 1)
830
+ this.upgrade = true
831
+ this.pauseParser()
832
+ return
833
+ }
834
+
835
+ this.headers = []
836
+ this.headersSize = 0
837
+
838
+ if (this.shouldKeepAlive && client[kPipelining]) {
839
+ const keepAliveTimeout = this.keepAlive
840
+ ? util.parseKeepAliveTimeout(this.keepAlive)
841
+ : null
842
+
843
+ if (keepAliveTimeout != null) {
844
+ const timeout = Math.min(
845
+ keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
846
+ client[kKeepAliveMaxTimeout]
847
+ )
848
+ if (timeout <= 0) {
849
+ socket[kReset] = true
850
+ } else {
851
+ client[kKeepAliveTimeoutValue] = timeout
852
+ }
853
+ } else {
854
+ client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout]
855
+ }
856
+ } else {
857
+ socket[kReset] = true
858
+ }
859
+
860
+ const pause =
861
+ request.onResponseStart(
862
+ statusCode,
863
+ headers,
864
+ this.resume,
865
+ statusText
866
+ ) === false
867
+
868
+ if (request.aborted) {
869
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Request aborted')
870
+ }
871
+
872
+ if (request.method === 'HEAD' || statusCode < 200) {
873
+ this.setShouldSkipBody(true)
874
+ }
875
+
876
+ this.headersSuspended = true
877
+ if (
878
+ !pause &&
879
+ request.method !== 'HEAD' &&
880
+ statusCode >= 200 &&
881
+ statusCode !== 204 &&
882
+ statusCode !== 205 &&
883
+ statusCode !== 304 &&
884
+ bodyKind === BODY_KIND_CONTENT_LENGTH &&
885
+ contentLength > 0 &&
886
+ !hasTrailers
887
+ ) {
888
+ this.directBodyRemaining = contentLength
889
+ }
890
+
891
+ if (socket[kBlocking]) {
892
+ socket[kBlocking] = false
893
+ client[kResume]()
894
+ }
895
+
896
+ if (pause) {
897
+ this.pauseParser()
898
+ this[kPausedByHandler] = true
899
+ } else if (
900
+ request.method === 'HEAD' ||
901
+ statusCode < 200 ||
902
+ statusCode === 204 ||
903
+ statusCode === 205 ||
904
+ statusCode === 304 ||
905
+ (bodyKind === BODY_KIND_CONTENT_LENGTH && contentLength === 0)
906
+ ) {
907
+ this.directBodyCompletePending = true
908
+ }
909
+
910
+ break
911
+ }
912
+ case milo.EVENT_DATA: {
913
+ const at = this.parserEvents.readUInt32LE(cursor + 1)
914
+ const len = this.parserEvents.readUInt32LE(cursor + 5)
915
+ const { client, socket, statusCode, maxResponseSize } = this
916
+
917
+ if (socket.destroyed) {
918
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Other side closed')
919
+ }
920
+
921
+ const request = client[kQueue][client[kRunningIdx]]
922
+ assert(request)
923
+ assert(this.timeoutType === TIMEOUT_BODY)
924
+
925
+ if (this.timeout?.refresh) {
926
+ this.timeout.refresh()
927
+ }
928
+
929
+ assert(statusCode >= 200)
930
+
931
+ if (maxResponseSize > -1 && this.bytesRead + len > maxResponseSize) {
932
+ util.destroy(socket, new ResponseExceededMaxSizeError())
933
+ return this.fail(
934
+ milo.ERROR_CALLBACK_ERROR,
935
+ 'Response size exceeded'
936
+ )
937
+ }
938
+
939
+ this.bytesRead += len
940
+
941
+ const buffer = currentBufferRef
942
+ if (
943
+ request.onResponseData(
944
+ new FastBuffer(buffer.buffer, buffer.byteOffset + at, len)
945
+ ) === false
946
+ ) {
947
+ this.pauseParser()
948
+ this[kPausedByHandler] = true
949
+ }
950
+
951
+ break
952
+ }
953
+ case milo.EVENT_TRAILER_NAME: {
954
+ const at = this.parserEvents.readUInt32LE(cursor + 1)
955
+ const len = this.parserEvents.readUInt32LE(cursor + 5)
956
+ const data =
957
+ len > 0
958
+ ? new FastBuffer(
959
+ currentBufferRef.buffer,
960
+ currentBufferRef.byteOffset + at,
961
+ len
962
+ )
963
+ : EMPTY_BUF
964
+
965
+ this.trailers.push(data)
966
+
967
+ this.trailersSize += len
968
+ if (this.trailersSize >= this.headersMaxSize) {
969
+ util.destroy(this.socket, new HeadersOverflowError())
970
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Headers overflow')
971
+ }
972
+
973
+ break
974
+ }
975
+ case milo.EVENT_TRAILER_VALUE: {
976
+ const at = this.parserEvents.readUInt32LE(cursor + 1)
977
+ const len = this.parserEvents.readUInt32LE(cursor + 5)
978
+ const data =
979
+ len > 0
980
+ ? new FastBuffer(
981
+ currentBufferRef.buffer,
982
+ currentBufferRef.byteOffset + at,
983
+ len
984
+ )
985
+ : EMPTY_BUF
986
+
987
+ this.trailers.push(data)
988
+
989
+ this.trailersSize += len
990
+ if (this.trailersSize >= this.headersMaxSize) {
991
+ util.destroy(this.socket, new HeadersOverflowError())
992
+ return this.fail(milo.ERROR_CALLBACK_ERROR, 'Headers overflow')
993
+ }
994
+
995
+ break
996
+ }
997
+ default:
998
+ return
999
+ }
1000
+
1001
+ cursor += eventLen
1002
+ }
1003
+ }
1004
+
1005
+ fail (code, message) {
1006
+ this.milo.fail(this.parser, code, message)
1007
+ this.errored = true
1008
+ }
1009
+
1010
+ onUpgrade (head) {
1011
+ const { upgrade, client, socket, headers, statusCode } = this
1012
+
1013
+ assert(upgrade)
1014
+ assert(client[kSocket] === socket)
1015
+ assert(!socket.destroyed)
1016
+ assert(!this.paused)
1017
+
1018
+ const request = client[kQueue][client[kRunningIdx]]
1019
+ assert(request)
1020
+ assert(request.upgrade || request.method === 'CONNECT')
1021
+
1022
+ this.statusCode = 0
1023
+ this.statusText = ''
1024
+ this.shouldKeepAlive = false
1025
+ this.headers = []
1026
+ this.headersSize = 0
1027
+
1028
+ socket.unshift(head)
1029
+ socket[kParser].destroy()
1030
+ socket[kParser] = null
1031
+ socket[kClient] = null
1032
+ socket[kError] = null
1033
+
1034
+ removeAllListeners(socket)
1035
+
1036
+ client[kSocket] = null
1037
+ client[kHTTPContext] = null
1038
+ client[kQueue][client[kRunningIdx]++] = null
1039
+ client.emit(
1040
+ 'disconnect',
1041
+ client[kUrl],
1042
+ [client],
1043
+ new InformationalError('upgrade')
1044
+ )
1045
+
1046
+ try {
1047
+ request.onRequestUpgrade(statusCode, headers, socket)
1048
+ } catch (err) {
1049
+ util.destroy(socket, err)
1050
+ }
1051
+
1052
+ client[kResume]()
1053
+ }
1054
+ }
1055
+
1056
+ function setMiloEnabled (value) {
1057
+ miloEnabled = value
1058
+ }
1059
+
1060
+ function getMiloEnabled () {
1061
+ return miloEnabled
1062
+ }
1063
+
1064
+ module.exports = { H1Parser, getMiloEnabled, setMiloEnabled }