@entelligentsia/forgecli 0.7.10 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/dist/CHANGELOG-forge-plugin.md +70 -0
- package/dist/CHANGELOG-pi.md +63 -0
- package/dist/bin/argv.d.ts +2 -2
- package/dist/bin/argv.js +10 -0
- package/dist/bin/argv.js.map +1 -1
- package/dist/bin/env-defaults.d.ts +1 -0
- package/dist/bin/env-defaults.js +13 -0
- package/dist/bin/env-defaults.js.map +1 -0
- package/dist/bin/forge.js +9 -0
- package/dist/bin/forge.js.map +1 -1
- package/dist/bin/update-cli.d.ts +9 -0
- package/dist/bin/update-cli.js +120 -0
- package/dist/bin/update-cli.js.map +1 -0
- package/dist/extensions/forgecli/index.js +3 -3
- package/dist/extensions/forgecli/index.js.map +1 -1
- package/dist/extensions/forgecli/update-check.js +1 -1
- package/dist/extensions/forgecli/update-check.js.map +1 -1
- package/dist/extensions/forgecli/whats-new-widget.d.ts +5 -5
- package/dist/extensions/forgecli/whats-new-widget.js +11 -11
- package/dist/extensions/forgecli/whats-new-widget.js.map +1 -1
- package/dist/extensions/forgecli/whats-new.js +6 -5
- package/dist/extensions/forgecli/whats-new.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +27 -98
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +62 -132
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +25 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +17 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +8 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +17 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +63 -0
- package/node_modules/@earendil-works/pi-coding-agent/README.md +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js +6 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +12 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +30 -15
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +23 -13
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts +4 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +58 -38
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js +0 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +3 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +7 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +6 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +3 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts +7 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +60 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +1 -3
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
- package/node_modules/@earendil-works/pi-tui/package.json +2 -2
- package/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/fetch/index.d.ts +7 -7
- package/node_modules/@protobufjs/fetch/index.js +4 -7
- package/node_modules/@protobufjs/fetch/package.json +7 -5
- package/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
- package/node_modules/@protobufjs/fetch/tests/index.js +150 -8
- package/node_modules/@protobufjs/fetch/util/fs.js +11 -0
- package/node_modules/@protobufjs/inquire/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/inquire/index.d.ts +1 -0
- package/node_modules/@protobufjs/inquire/index.js +1 -0
- package/node_modules/@protobufjs/inquire/package.json +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.js +187 -153
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +14 -5
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.js +207 -173
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +6 -3
- package/node_modules/protobufjs/src/util/fs.js +11 -0
- package/node_modules/protobufjs/src/util/minimal.js +10 -2
- package/node_modules/protobufjs/src/util.js +1 -1
- package/node_modules/undici/README.md +14 -5
- package/node_modules/undici/docs/docs/api/Client.md +4 -2
- package/node_modules/undici/docs/docs/api/Dispatcher.md +62 -27
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +7 -5
- package/node_modules/undici/docs/docs/api/H2CClient.md +1 -1
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +14 -9
- package/node_modules/undici/docs/docs/api/RetryAgent.md +0 -1
- package/node_modules/undici/docs/docs/api/RetryHandler.md +12 -14
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +23 -0
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +231 -0
- package/node_modules/undici/index.js +4 -2
- package/node_modules/undici/lib/api/api-connect.js +13 -11
- package/node_modules/undici/lib/api/api-pipeline.js +26 -13
- package/node_modules/undici/lib/api/api-request.js +45 -21
- package/node_modules/undici/lib/api/api-stream.js +81 -20
- package/node_modules/undici/lib/api/api-upgrade.js +21 -11
- package/node_modules/undici/lib/api/readable.js +3 -2
- package/node_modules/undici/lib/cache/memory-cache-store.js +1 -1
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +6 -4
- package/node_modules/undici/lib/core/connect.js +17 -1
- package/node_modules/undici/lib/core/constants.js +1 -24
- package/node_modules/undici/lib/core/errors.js +2 -2
- package/node_modules/undici/lib/core/request.js +115 -18
- package/node_modules/undici/lib/core/socks5-client.js +24 -9
- package/node_modules/undici/lib/core/socks5-utils.js +32 -23
- package/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/undici/lib/core/util.js +70 -43
- package/node_modules/undici/lib/dispatcher/agent.js +47 -33
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +21 -26
- package/node_modules/undici/lib/dispatcher/client-h1.js +98 -39
- package/node_modules/undici/lib/dispatcher/client-h2.js +603 -272
- package/node_modules/undici/lib/dispatcher/client.js +12 -5
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +24 -5
- package/node_modules/undici/lib/dispatcher/dispatcher.js +0 -4
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +107 -0
- package/node_modules/undici/lib/dispatcher/h2c-client.js +5 -5
- package/node_modules/undici/lib/dispatcher/pool-base.js +28 -10
- package/node_modules/undici/lib/dispatcher/pool.js +31 -6
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +38 -13
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +31 -9
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +95 -80
- package/node_modules/undici/lib/global.js +13 -1
- package/node_modules/undici/lib/handler/cache-handler.js +16 -8
- package/node_modules/undici/lib/handler/decorator-handler.js +1 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -51
- package/node_modules/undici/lib/handler/retry-handler.js +15 -2
- package/node_modules/undici/lib/interceptor/cache.js +30 -17
- package/node_modules/undici/lib/interceptor/decompress.js +28 -2
- package/node_modules/undici/lib/interceptor/dns.js +1 -1
- package/node_modules/undici/lib/interceptor/redirect.js +3 -3
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +1 -1
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +1 -1
- package/node_modules/undici/lib/mock/mock-agent.js +8 -8
- package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
- package/node_modules/undici/lib/mock/mock-utils.js +37 -22
- package/node_modules/undici/lib/mock/snapshot-agent.js +16 -6
- package/node_modules/undici/lib/mock/snapshot-recorder.js +38 -3
- package/node_modules/undici/lib/util/cache.js +8 -7
- package/node_modules/undici/lib/util/runtime-features.js +3 -34
- package/node_modules/undici/lib/web/cache/cache.js +6 -8
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
- package/node_modules/undici/lib/web/fetch/body.js +3 -9
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +21 -2
- package/node_modules/undici/lib/web/fetch/index.js +214 -221
- package/node_modules/undici/lib/web/webidl/index.js +7 -9
- package/node_modules/undici/lib/web/websocket/frame.js +1 -7
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
- package/node_modules/undici/lib/web/websocket/receiver.js +62 -22
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +11 -17
- package/node_modules/undici/lib/web/websocket/websocket.js +6 -1
- package/node_modules/undici/package.json +9 -9
- package/node_modules/undici/types/agent.d.ts +0 -2
- package/node_modules/undici/types/client.d.ts +25 -19
- package/node_modules/undici/types/dispatcher.d.ts +7 -27
- package/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/undici/types/formdata.d.ts +0 -6
- package/node_modules/undici/types/h2c-client.d.ts +6 -6
- package/node_modules/undici/types/header.d.ts +5 -0
- package/node_modules/undici/types/index.d.ts +3 -1
- package/node_modules/undici/types/interceptors.d.ts +1 -1
- package/node_modules/undici/types/pool.d.ts +0 -2
- package/node_modules/undici/types/proxy-agent.d.ts +2 -2
- package/node_modules/undici/types/round-robin-pool.d.ts +0 -2
- package/node_modules/undici/types/snapshot-agent.d.ts +4 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -2
- package/node_modules/undici/types/webidl.d.ts +0 -1
- package/package.json +7 -8
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +0 -92
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +0 -31
- package/node_modules/undici/lib/handler/unwrap-handler.js +0 -100
- package/node_modules/undici/lib/handler/wrap-handler.js +0 -105
- package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/node_modules/undici/lib/util/promise.js +0 -28
- package/skills/refresh-kb-links/SKILL.md +0 -217
- package/skills/store-custodian/SKILL.md +0 -163
- package/skills/store-query-grammar/SKILL.md +0 -145
- package/skills/store-query-nlp/SKILL.md +0 -110
|
@@ -69,9 +69,9 @@ function lazyllhttp () {
|
|
|
69
69
|
let useWasmSIMD = process.arch !== 'ppc64'
|
|
70
70
|
// The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior
|
|
71
71
|
if (process.env.UNDICI_NO_WASM_SIMD === '1') {
|
|
72
|
-
useWasmSIMD = true
|
|
73
|
-
} else if (process.env.UNDICI_NO_WASM_SIMD === '0') {
|
|
74
72
|
useWasmSIMD = false
|
|
73
|
+
} else if (process.env.UNDICI_NO_WASM_SIMD === '0') {
|
|
74
|
+
useWasmSIMD = true
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (useWasmSIMD) {
|
|
@@ -188,6 +188,7 @@ let currentBufferRef = null
|
|
|
188
188
|
*/
|
|
189
189
|
let currentBufferSize = 0
|
|
190
190
|
let currentBufferPtr = null
|
|
191
|
+
let currentBuffer = null
|
|
191
192
|
|
|
192
193
|
const USE_NATIVE_TIMER = 0
|
|
193
194
|
const USE_FAST_TIMER = 1
|
|
@@ -216,6 +217,7 @@ class Parser {
|
|
|
216
217
|
*/
|
|
217
218
|
this.socket = socket
|
|
218
219
|
this.timeout = null
|
|
220
|
+
this.timeoutWeakRef = new WeakRef(this)
|
|
219
221
|
this.timeoutValue = null
|
|
220
222
|
this.timeoutType = null
|
|
221
223
|
this.statusCode = 0
|
|
@@ -231,8 +233,8 @@ class Parser {
|
|
|
231
233
|
this.bytesRead = 0
|
|
232
234
|
|
|
233
235
|
this.keepAlive = ''
|
|
234
|
-
this.contentLength =
|
|
235
|
-
this.
|
|
236
|
+
this.contentLength = -1
|
|
237
|
+
this.connectionKeepAlive = false
|
|
236
238
|
this.maxResponseSize = client[kMaxResponseSize]
|
|
237
239
|
}
|
|
238
240
|
|
|
@@ -253,9 +255,9 @@ class Parser {
|
|
|
253
255
|
|
|
254
256
|
if (delay) {
|
|
255
257
|
if (type & USE_FAST_TIMER) {
|
|
256
|
-
this.timeout = timers.setFastTimeout(onParserTimeout, delay,
|
|
258
|
+
this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef)
|
|
257
259
|
} else {
|
|
258
|
-
this.timeout = setTimeout(onParserTimeout, delay,
|
|
260
|
+
this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef)
|
|
259
261
|
this.timeout?.unref()
|
|
260
262
|
}
|
|
261
263
|
}
|
|
@@ -322,7 +324,16 @@ class Parser {
|
|
|
322
324
|
currentBufferPtr = llhttp.malloc(currentBufferSize)
|
|
323
325
|
}
|
|
324
326
|
|
|
325
|
-
|
|
327
|
+
if (
|
|
328
|
+
currentBuffer === null ||
|
|
329
|
+
currentBuffer.buffer !== llhttp.memory.buffer ||
|
|
330
|
+
currentBuffer.byteOffset !== currentBufferPtr ||
|
|
331
|
+
currentBuffer.byteLength !== currentBufferSize
|
|
332
|
+
) {
|
|
333
|
+
currentBuffer = new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
currentBuffer.set(chunk)
|
|
326
337
|
|
|
327
338
|
// Call `execute` on the wasm parser.
|
|
328
339
|
// We pass the `llhttp_parser` pointer address, the pointer address of buffer view data,
|
|
@@ -349,16 +360,7 @@ class Parser {
|
|
|
349
360
|
this.paused = true
|
|
350
361
|
socket.unshift(data)
|
|
351
362
|
} else {
|
|
352
|
-
|
|
353
|
-
let message = ''
|
|
354
|
-
if (ptr) {
|
|
355
|
-
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
|
356
|
-
message =
|
|
357
|
-
'Response does not match the HTTP/1.1 protocol (' +
|
|
358
|
-
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
|
359
|
-
')'
|
|
360
|
-
}
|
|
361
|
-
throw new HTTPParserError(message, constants.ERROR[ret], data)
|
|
363
|
+
throw this.createError(ret, data)
|
|
362
364
|
}
|
|
363
365
|
}
|
|
364
366
|
} catch (err) {
|
|
@@ -366,6 +368,54 @@ class Parser {
|
|
|
366
368
|
}
|
|
367
369
|
}
|
|
368
370
|
|
|
371
|
+
finish () {
|
|
372
|
+
assert(currentParser === null)
|
|
373
|
+
assert(this.ptr != null)
|
|
374
|
+
assert(!this.paused)
|
|
375
|
+
|
|
376
|
+
const { llhttp } = this
|
|
377
|
+
|
|
378
|
+
let ret
|
|
379
|
+
|
|
380
|
+
try {
|
|
381
|
+
currentParser = this
|
|
382
|
+
ret = llhttp.llhttp_finish(this.ptr)
|
|
383
|
+
} finally {
|
|
384
|
+
currentParser = null
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (ret === constants.ERROR.OK) {
|
|
388
|
+
return null
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
|
|
392
|
+
this.paused = true
|
|
393
|
+
return null
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return this.createError(ret, EMPTY_BUF)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
createError (ret, data) {
|
|
400
|
+
const { llhttp, contentLength, bytesRead } = this
|
|
401
|
+
|
|
402
|
+
if (contentLength !== -1 && bytesRead !== contentLength) {
|
|
403
|
+
return new ResponseContentLengthMismatchError()
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
|
407
|
+
let message = ''
|
|
408
|
+
if (ptr) {
|
|
409
|
+
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
|
410
|
+
message =
|
|
411
|
+
'Response does not match the HTTP/1.1 protocol (' +
|
|
412
|
+
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
|
413
|
+
')'
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return new HTTPParserError(message, constants.ERROR[ret], data)
|
|
417
|
+
}
|
|
418
|
+
|
|
369
419
|
destroy () {
|
|
370
420
|
assert(currentParser === null)
|
|
371
421
|
assert(this.ptr != null)
|
|
@@ -447,10 +497,17 @@ class Parser {
|
|
|
447
497
|
if (headerName === 'keep-alive') {
|
|
448
498
|
this.keepAlive += buf.toString()
|
|
449
499
|
} else if (headerName === 'connection') {
|
|
450
|
-
this.
|
|
500
|
+
this.connectionKeepAlive =
|
|
501
|
+
this.headers[len - 1].length === 10 &&
|
|
502
|
+
util.bufferToLowerCasedHeaderName(this.headers[len - 1]) === 'keep-alive'
|
|
451
503
|
}
|
|
452
504
|
} else if (key.length === 14 && util.bufferToLowerCasedHeaderName(key) === 'content-length') {
|
|
453
|
-
this.contentLength
|
|
505
|
+
if (this.contentLength === -1) {
|
|
506
|
+
this.contentLength = 0
|
|
507
|
+
}
|
|
508
|
+
for (let i = 0; i < buf.length; i++) {
|
|
509
|
+
this.contentLength = (this.contentLength * 10) + (buf[i] - 0x30)
|
|
510
|
+
}
|
|
454
511
|
}
|
|
455
512
|
|
|
456
513
|
this.trackHeader(buf.length)
|
|
@@ -507,7 +564,7 @@ class Parser {
|
|
|
507
564
|
client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'))
|
|
508
565
|
|
|
509
566
|
try {
|
|
510
|
-
request.
|
|
567
|
+
request.onRequestUpgrade(statusCode, headers, socket)
|
|
511
568
|
} catch (err) {
|
|
512
569
|
util.destroy(socket, err)
|
|
513
570
|
}
|
|
@@ -554,7 +611,7 @@ class Parser {
|
|
|
554
611
|
this.shouldKeepAlive = (
|
|
555
612
|
shouldKeepAlive ||
|
|
556
613
|
// Override llhttp value which does not allow keepAlive for HEAD.
|
|
557
|
-
(request.method === 'HEAD' && !socket[kReset] && this.
|
|
614
|
+
(request.method === 'HEAD' && !socket[kReset] && this.connectionKeepAlive)
|
|
558
615
|
)
|
|
559
616
|
|
|
560
617
|
if (this.statusCode >= 200) {
|
|
@@ -605,7 +662,7 @@ class Parser {
|
|
|
605
662
|
socket[kReset] = true
|
|
606
663
|
}
|
|
607
664
|
|
|
608
|
-
const pause = request.
|
|
665
|
+
const pause = request.onResponseStart(statusCode, headers, this.resume, statusText) === false
|
|
609
666
|
|
|
610
667
|
if (request.aborted) {
|
|
611
668
|
return -1
|
|
@@ -657,7 +714,7 @@ class Parser {
|
|
|
657
714
|
|
|
658
715
|
this.bytesRead += buf.length
|
|
659
716
|
|
|
660
|
-
if (request.
|
|
717
|
+
if (request.onResponseData(buf) === false) {
|
|
661
718
|
return constants.ERROR.PAUSED
|
|
662
719
|
}
|
|
663
720
|
|
|
@@ -687,9 +744,9 @@ class Parser {
|
|
|
687
744
|
this.statusCode = 0
|
|
688
745
|
this.statusText = ''
|
|
689
746
|
this.bytesRead = 0
|
|
690
|
-
this.contentLength =
|
|
747
|
+
this.contentLength = -1
|
|
691
748
|
this.keepAlive = ''
|
|
692
|
-
this.
|
|
749
|
+
this.connectionKeepAlive = false
|
|
693
750
|
|
|
694
751
|
this.headers = []
|
|
695
752
|
this.headersSize = 0
|
|
@@ -698,12 +755,12 @@ class Parser {
|
|
|
698
755
|
return 0
|
|
699
756
|
}
|
|
700
757
|
|
|
701
|
-
if (request.method !== 'HEAD' && contentLength && bytesRead !==
|
|
758
|
+
if (request.method !== 'HEAD' && contentLength !== -1 && bytesRead !== contentLength) {
|
|
702
759
|
util.destroy(socket, new ResponseContentLengthMismatchError())
|
|
703
760
|
return -1
|
|
704
761
|
}
|
|
705
762
|
|
|
706
|
-
request.
|
|
763
|
+
request.onResponseEnd(headers)
|
|
707
764
|
|
|
708
765
|
client[kQueue][client[kRunningIdx]++] = null
|
|
709
766
|
|
|
@@ -870,8 +927,11 @@ function onHttpSocketError (err) {
|
|
|
870
927
|
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
|
871
928
|
// to the user.
|
|
872
929
|
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
|
873
|
-
|
|
874
|
-
|
|
930
|
+
const parserErr = parser.finish()
|
|
931
|
+
if (parserErr) {
|
|
932
|
+
this[kError] = parserErr
|
|
933
|
+
this[kClient][kOnError](parserErr)
|
|
934
|
+
}
|
|
875
935
|
return
|
|
876
936
|
}
|
|
877
937
|
|
|
@@ -888,8 +948,10 @@ function onHttpSocketEnd () {
|
|
|
888
948
|
const parser = this[kParser]
|
|
889
949
|
|
|
890
950
|
if (parser.statusCode && !parser.shouldKeepAlive) {
|
|
891
|
-
|
|
892
|
-
|
|
951
|
+
const parserErr = parser.finish()
|
|
952
|
+
if (parserErr) {
|
|
953
|
+
util.destroy(this, parserErr)
|
|
954
|
+
}
|
|
893
955
|
return
|
|
894
956
|
}
|
|
895
957
|
|
|
@@ -901,8 +963,7 @@ function onHttpSocketClose () {
|
|
|
901
963
|
|
|
902
964
|
if (parser) {
|
|
903
965
|
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
|
904
|
-
|
|
905
|
-
parser.onMessageComplete()
|
|
966
|
+
this[kError] = parser.finish() || this[kError]
|
|
906
967
|
}
|
|
907
968
|
|
|
908
969
|
this[kParser].destroy()
|
|
@@ -1078,7 +1139,7 @@ function writeH1 (client, request) {
|
|
|
1078
1139
|
}
|
|
1079
1140
|
|
|
1080
1141
|
try {
|
|
1081
|
-
request.
|
|
1142
|
+
request.onRequestStart(abort, null)
|
|
1082
1143
|
} catch (err) {
|
|
1083
1144
|
util.errorRequest(client, request, err)
|
|
1084
1145
|
}
|
|
@@ -1106,7 +1167,7 @@ function writeH1 (client, request) {
|
|
|
1106
1167
|
socket[kReset] = reset
|
|
1107
1168
|
}
|
|
1108
1169
|
|
|
1109
|
-
if (client[kMaxRequests] && socket[kCounter]
|
|
1170
|
+
if (client[kMaxRequests] && ++socket[kCounter] >= client[kMaxRequests]) {
|
|
1110
1171
|
socket[kReset] = true
|
|
1111
1172
|
}
|
|
1112
1173
|
|
|
@@ -1364,8 +1425,6 @@ function writeBuffer (abort, body, client, request, socket, contentLength, heade
|
|
|
1364
1425
|
* @returns {Promise<void>}
|
|
1365
1426
|
*/
|
|
1366
1427
|
async function writeBlob (abort, body, client, request, socket, contentLength, header, expectsPayload) {
|
|
1367
|
-
assert(contentLength === body.size, 'blob body must have content length')
|
|
1368
|
-
|
|
1369
1428
|
try {
|
|
1370
1429
|
if (contentLength != null && contentLength !== body.size) {
|
|
1371
1430
|
throw new RequestContentLengthMismatchError()
|
|
@@ -1477,7 +1536,7 @@ class AsyncWriter {
|
|
|
1477
1536
|
}
|
|
1478
1537
|
|
|
1479
1538
|
/**
|
|
1480
|
-
* @param {
|
|
1539
|
+
* @param {string|Uint8Array} chunk
|
|
1481
1540
|
* @returns
|
|
1482
1541
|
*/
|
|
1483
1542
|
write (chunk) {
|
|
@@ -1491,7 +1550,7 @@ class AsyncWriter {
|
|
|
1491
1550
|
return false
|
|
1492
1551
|
}
|
|
1493
1552
|
|
|
1494
|
-
const len = Buffer.byteLength(chunk)
|
|
1553
|
+
const len = chunk instanceof Uint8Array ? chunk.byteLength : Buffer.byteLength(chunk)
|
|
1495
1554
|
if (!len) {
|
|
1496
1555
|
return true
|
|
1497
1556
|
}
|