fix(web): accept empty chunked API POST requests

Handle untyped zero-byte POST streams at the shared API parser boundary.
Keep request.body undefined and preserve existing typed parsers, 404
fallbacks, authentication and webview proxy stream handling.

Reject nonempty untyped streams on the first byte, and cover parser
boundaries, raw HTTP framing and real WebServer routing with regressions.
This commit is contained in:
kdxcxs committed 2026-10-27 16:22:00 +08:00
1 parent 3e06f3c141
commit b0487cc9af
4 files changed
+487

No files matched your search

+4
View File
@@ -194,6 +194,7 @@ import {
import { isMultiUserMode } from '../config/multiuser.js';
import { bootstrapInitialAdmin, hasUsers, resolveClaudeModeForUsername } from '../user-store.js';
import { installRouteErrorHandler } from './route-error-handler.js';
import { installEmptyApiPostParser } from './request-body-parser.js';
import { isExplicitlyEnabled, isLoopbackBindHost, buildHostPolicy, type HostPolicy } from './network-auth-policy.js';
import {
registerPushRoutes,
@@ -970,6 +971,9 @@ export class WebServer extends EventEmitter {
this.userIpFailures = authState.userIpFailures;
}
// Bodyless API POSTs may arrive as empty chunked streams through a proxy.
installEmptyApiPostParser(this.app);
// WebSocket support (terminal I/O — low-latency bidirectional channel)
await this.app.register(fastifyWebsocket);