@morojs/moro 1.8.13 → 1.8.15

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.
@@ -13,6 +13,7 @@ export interface Http2ServerOptions {
13
13
  limits?: HttpRuntimeLimits;
14
14
  settings?: {
15
15
  headerTableSize?: number;
16
+ /** Accepted for compatibility but never sent: RFC 9113 forbids a server from advertising ENABLE_PUSH=1 (clients drop the connection), and whether push is possible is the client's setting, read per stream. */
16
17
  enablePush?: boolean;
17
18
  initialWindowSize?: number;
18
19
  maxFrameSize?: number;
@@ -28,6 +29,7 @@ export declare class MoroHttp2Server {
28
29
  private globalMiddleware;
29
30
  private compressionEnabled;
30
31
  private compressionThreshold;
32
+ private compressionMaxInlineBytes;
31
33
  private requestTrackingEnabled;
32
34
  private multipartLimits?;
33
35
  private _limits?;
@@ -56,6 +58,7 @@ export declare class MoroHttp2Server {
56
58
  compression?: {
57
59
  enabled: boolean;
58
60
  threshold?: number;
61
+ maxInlineBytes?: number;
59
62
  };
60
63
  minimal?: boolean;
61
64
  }): void;
@@ -14,13 +14,22 @@ function http2() {
14
14
  }
15
15
  let gzip;
16
16
  let deflate;
17
+ let gzipSync;
18
+ let deflateSync;
17
19
  function compressors() {
18
20
  if (!gzip) {
19
21
  const zlib = requireBuiltin('zlib');
20
22
  gzip = promisify(zlib.gzip);
21
23
  deflate = promisify(zlib.deflate);
24
+ gzipSync = (buf) => zlib.gzipSync(buf);
25
+ deflateSync = (buf) => zlib.deflateSync(buf);
22
26
  }
23
- return { gzip: gzip, deflate: deflate };
27
+ return {
28
+ gzip: gzip,
29
+ deflate: deflate,
30
+ gzipSync: gzipSync,
31
+ deflateSync: deflateSync,
32
+ };
24
33
  }
25
34
  export class MoroHttp2Server {
26
35
  server;
@@ -28,6 +37,8 @@ export class MoroHttp2Server {
28
37
  globalMiddleware = [];
29
38
  compressionEnabled = true;
30
39
  compressionThreshold = 1024;
40
+ // Bodies at or below this size compress on the calling thread; 0 = never
41
+ compressionMaxInlineBytes = 16384;
31
42
  requestTrackingEnabled = true;
32
43
  multipartLimits;
33
44
  _limits;
@@ -88,11 +99,15 @@ export class MoroHttp2Server {
88
99
  serverOptions.ca = options.ca;
89
100
  }
90
101
  }
91
- // Add HTTP/2 settings
102
+ // Add HTTP/2 settings. SETTINGS_ENABLE_PUSH is never sent: RFC 9113
103
+ // §6.5.2 forbids a server from advertising it as 1, and nghttp2 (curl,
104
+ // Node's own client, browsers) treats that frame as a connection-level
105
+ // PROTOCOL_ERROR - every stream died before its response could be read.
106
+ // Whether push is possible is the CLIENT's setting, read per stream from
107
+ // stream.pushAllowed, so settings.enablePush changes nothing on the wire.
92
108
  if (options.settings) {
93
109
  serverOptions.settings = {
94
110
  headerTableSize: options.settings.headerTableSize,
95
- enablePush: options.settings.enablePush !== false,
96
111
  initialWindowSize: options.settings.initialWindowSize || 65535,
97
112
  maxFrameSize: options.settings.maxFrameSize || 16384,
98
113
  maxConcurrentStreams: options.settings.maxConcurrentStreams || 100,
@@ -103,7 +118,6 @@ export class MoroHttp2Server {
103
118
  }
104
119
  else {
105
120
  serverOptions.settings = {
106
- enablePush: true,
107
121
  initialWindowSize: 65535,
108
122
  maxFrameSize: 16384,
109
123
  maxConcurrentStreams: 100,
@@ -153,6 +167,9 @@ export class MoroHttp2Server {
153
167
  if (config.compression.threshold !== undefined) {
154
168
  this.compressionThreshold = config.compression.threshold;
155
169
  }
170
+ if (config.compression.maxInlineBytes !== undefined) {
171
+ this.compressionMaxInlineBytes = config.compression.maxInlineBytes;
172
+ }
156
173
  }
157
174
  if (config.minimal) {
158
175
  this.compressionEnabled = false;
@@ -436,6 +453,7 @@ export class MoroHttp2Server {
436
453
  _poolManager: this.poolManager,
437
454
  _compressionEnabled: this.compressionEnabled,
438
455
  _compressionThreshold: this.compressionThreshold,
456
+ _compressionMaxInlineBytes: this.compressionMaxInlineBytes,
439
457
  };
440
458
  // Status method
441
459
  httpRes.status = (code) => {
@@ -464,6 +482,25 @@ export class MoroHttp2Server {
464
482
  httpRes.getHeaders = () => {
465
483
  return { ...httpRes._headers };
466
484
  };
485
+ // Event surface for middleware written against Node's ServerResponse -
486
+ // the built-in request logger, Prometheus, CloudWatch and performance
487
+ // monitors all call res.on('finish', ...). This response is a plain
488
+ // object, so its events are the stream's: a Duplex emits 'finish' once
489
+ // the body has been flushed and 'close' when the stream is gone, the two
490
+ // events ServerResponse fires. Without these, enabling request logging
491
+ // (the default) turned every HTTP/2 request into a 500.
492
+ httpRes.on = (event, listener) => {
493
+ stream.on(event, listener);
494
+ return httpRes;
495
+ };
496
+ httpRes.once = (event, listener) => {
497
+ stream.once(event, listener);
498
+ return httpRes;
499
+ };
500
+ httpRes.off = httpRes.removeListener = (event, listener) => {
501
+ stream.off(event, listener);
502
+ return httpRes;
503
+ };
467
504
  // JSON response
468
505
  httpRes.json = async (data) => {
469
506
  if (httpRes.headersSent || stream.destroyed)
@@ -475,7 +512,11 @@ export class MoroHttp2Server {
475
512
  if (httpRes._compressionEnabled && finalBuffer.length > httpRes._compressionThreshold) {
476
513
  const acceptEncoding = req.headers['accept-encoding'];
477
514
  if (acceptEncoding && acceptEncoding.includes('gzip')) {
478
- const compressed = await compressors().gzip(finalBuffer);
515
+ // A small body is compressed on this thread (see compressionMaxInlineBytes)
516
+ const compressed = httpRes._compressionMaxInlineBytes > 0 &&
517
+ finalBuffer.length <= httpRes._compressionMaxInlineBytes
518
+ ? compressors().gzipSync(finalBuffer)
519
+ : await compressors().gzip(finalBuffer);
479
520
  httpRes._headers['content-encoding'] = 'gzip';
480
521
  httpRes._headers['content-length'] = compressed.length;
481
522
  stream.respond({
@@ -487,7 +528,10 @@ export class MoroHttp2Server {
487
528
  return;
488
529
  }
489
530
  else if (acceptEncoding && acceptEncoding.includes('deflate')) {
490
- const compressed = await compressors().deflate(finalBuffer);
531
+ const compressed = httpRes._compressionMaxInlineBytes > 0 &&
532
+ finalBuffer.length <= httpRes._compressionMaxInlineBytes
533
+ ? compressors().deflateSync(finalBuffer)
534
+ : await compressors().deflate(finalBuffer);
491
535
  httpRes._headers['content-encoding'] = 'deflate';
492
536
  httpRes._headers['content-length'] = compressed.length;
493
537
  stream.respond({
@@ -512,14 +556,14 @@ export class MoroHttp2Server {
512
556
  if (httpRes.headersSent || stream.destroyed)
513
557
  return;
514
558
  if (!httpRes._headers['content-type']) {
559
+ // The same sniff the engine and Node servers use: a body that starts
560
+ // with '{' or '[' is JSON, anything else text. Parsing the whole body
561
+ // to decide cost a JSON.parse per response and labelled a bare number
562
+ // or `true` as JSON.
515
563
  if (typeof data === 'string') {
516
- try {
517
- JSON.parse(data);
518
- httpRes._headers['content-type'] = 'application/json; charset=utf-8';
519
- }
520
- catch {
521
- httpRes._headers['content-type'] = 'text/plain; charset=utf-8';
522
- }
564
+ httpRes._headers['content-type'] = /^\s*[{[]/.test(data)
565
+ ? 'application/json; charset=utf-8'
566
+ : 'text/plain; charset=utf-8';
523
567
  }
524
568
  else {
525
569
  httpRes._headers['content-type'] = 'application/octet-stream';
@@ -1 +1 @@
1
- {"version":3,"file":"http2-server.js","sourceRoot":"","sources":["../../../src/core/http/http2-server.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,cAAc,IAAI,oBAAoB,GAEvC,MAAM,6BAA6B,CAAC;AAGrC,4EAA4E;AAC5E,2EAA2E;AAC3E,uBAAuB;AACvB,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAEjD,IAAI,QAA4C,CAAC;AACjD,SAAS,KAAK;IACZ,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC,O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AAC;IAED,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC5B,IAAI,UAAU,EAAE,EAAE,EAAE,CAAC;YACnB,UAAU,CAAC,EAAE,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,GAQT;QACC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAa,CAAC;QAClC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mBAAmB;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO;YACL,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,oBAAoB,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ;YACnD,WAAW,EAAE,SAAS;SACvB,CAAC;IACJ,CAAC","sourcesContent":["// HTTP/2 Server Implementation for Moro Framework\n//\n// `node:http2` and `node:zlib` are resolved on first use, not at import time.\n// framework.ts imports this module unconditionally (it has to - the HTTP/2\n// branch is chosen at construction), but the vast majority of apps never take\n// that branch. Loading node:http2 eagerly costs every app ~1 MB RSS on top of\n// http/https, and the zlib compressors another ~0.3 MB, for code they never\n// run. Builtins are always synchronously requirable on every supported Node,\n// so this needs no dynamic import and no engines bump.\nimport type {\n Http2Server,\n Http2SecureServer,\n ServerHttp2Stream,\n IncomingHttpHeaders,\n OutgoingHttpHeaders,\n} from 'http2';\nimport { createRequire } from 'module';\nimport { promisify } from 'util';\nimport { createFrameworkLogger } from '../logger/index.js';\nimport {\n HttpRequest,\n HttpResponse,\n Middleware,\n HttpHandler,\n RouteEntry,\n} from '../../types/http.js';\nimport { PathMatcher } from '../routing/path-matcher.js';\nimport { ObjectPoolManager } from '../pooling/object-pool-manager.js';\nimport {\n parseMultipart as parseMultipartBuffer,\n type MultipartLimits,\n} from './utils/multipart-parser.js';\nimport type { HttpRuntimeLimits } from './utils/size.js';\n\n// Builtins only, so the base is irrelevant; 'file:///' keeps this compiling\n// under the CJS transform Jest applies to the test suite (import.meta is a\n// syntax error there).\nconst requireBuiltin = createRequire('file:///');\n\nlet http2Mod: typeof import('http2') | undefined;\nfunction http2(): typeof import('http2') {\n return (http2Mod ??= requireBuiltin('http2') as typeof import('http2'));\n}\n\nlet gzip: ((buf: Buffer) => Promise<Buffer>) | undefined;\nlet deflate: ((buf: Buffer) => Promise<Buffer>) | undefined;\nfunction compressors() {\n if (!gzip) {\n const zlib = requireBuiltin('zlib') as typeof import('zlib');\n gzip = promisify(zlib.gzip) as (buf: Buffer) => Promise<Buffer>;\n deflate = promisify(zlib.deflate) as (buf: Buffer) => Promise<Buffer>;\n }\n return { gzip: gzip, deflate: deflate as (buf: Buffer) => Promise<Buffer> };\n}\n\nexport interface Http2ServerOptions {\n key?: string | Buffer;\n cert?: string | Buffer;\n ca?: string | Buffer | Array<string | Buffer>;\n allowHTTP1?: boolean;\n maxSessionMemory?: number;\n maxBodySize?: number; // Maximum body size for JSON/form data\n maxUploadSize?: number; // Maximum size for file uploads\n /** Flattened runtime limits (timeouts, maxConnections, multipart, ...). */\n limits?: HttpRuntimeLimits;\n settings?: {\n headerTableSize?: number;\n enablePush?: boolean;\n initialWindowSize?: number;\n maxFrameSize?: number;\n maxConcurrentStreams?: number;\n maxHeaderListSize?: number;\n maxHeaderSize?: number;\n enableConnectProtocol?: boolean;\n };\n}\n\nexport class MoroHttp2Server {\n private server: Http2Server | Http2SecureServer;\n private routes: RouteEntry[] = [];\n private globalMiddleware: Middleware[] = [];\n private compressionEnabled = true;\n private compressionThreshold = 1024;\n private requestTrackingEnabled = true;\n private multipartLimits?: MultipartLimits;\n private _limits?: HttpRuntimeLimits;\n private logger = createFrameworkLogger('Http2Server');\n private hookManager: any;\n private requestCounter = 0;\n private isSecure: boolean;\n\n // Body size limits - defaults overridden by config in constructor\n private maxBodySize: number = 10 * 1024 * 1024; // Default 10MB (overridden by server.bodySizeLimit config)\n private maxUploadSize: number = 100 * 1024 * 1024; // Default 100MB for file uploads\n\n // Use shared object pool manager\n private poolManager = ObjectPoolManager.getInstance();\n\n // Interned method strings for fast comparison\n private static readonly METHOD_POST = 'POST';\n private static readonly METHOD_PUT = 'PUT';\n private static readonly METHOD_PATCH = 'PATCH';\n private static readonly METHOD_GET = 'GET';\n private static readonly METHOD_DELETE = 'DELETE';\n private static readonly METHOD_HEAD = 'HEAD';\n private static readonly METHOD_OPTIONS = 'OPTIONS';\n\n // Pre-compiled response templates\n private static readonly RESPONSE_TEMPLATES = {\n notFound: Buffer.from('{\"success\":false,\"error\":\"Not found\"}'),\n unauthorized: Buffer.from('{\"success\":false,\"error\":\"Unauthorized\"}'),\n forbidden: Buffer.from('{\"success\":false,\"error\":\"Forbidden\"}'),\n internalError: Buffer.from('{\"success\":false,\"error\":\"Internal server error\"}'),\n methodNotAllowed: Buffer.from('{\"success\":false,\"error\":\"Method not allowed\"}'),\n rateLimited: Buffer.from('{\"success\":false,\"error\":\"Rate limit exceeded\"}'),\n };\n\n // Route optimization structures\n private routeCache = new Map<string, RouteEntry | null>();\n private staticRoutes = new Map<string, RouteEntry>();\n private dynamicRoutes: RouteEntry[] = [];\n private routesBySegmentCount = new Map<number, RouteEntry[]>();\n private pathNormalizationCache = new Map<string, string>();\n\n constructor(options: Http2ServerOptions = {}) {\n this.isSecure = !!(options.key && options.cert);\n\n // Configure body size limits from options\n if (options.maxBodySize) {\n this.maxBodySize = options.maxBodySize;\n }\n if (options.maxUploadSize) {\n this.maxUploadSize = options.maxUploadSize;\n }\n if (options.limits?.multipart) this.multipartLimits = options.limits.multipart;\n if (options.limits) this._limits = options.limits;\n\n const serverOptions: any = {\n allowHTTP1: options.allowHTTP1 !== false,\n ...(options.maxSessionMemory && { maxSessionMemory: options.maxSessionMemory }),\n };\n\n // Add SSL options if secure\n if (this.isSecure) {\n serverOptions.key = options.key;\n serverOptions.cert = options.cert;\n if (options.ca) {\n serverOptions.ca = options.ca;\n }\n }\n\n // Add HTTP/2 settings\n if (options.settings) {\n serverOptions.settings = {\n headerTableSize: options.settings.headerTableSize,\n enablePush: options.settings.enablePush !== false,\n initialWindowSize: options.settings.initialWindowSize || 65535,\n maxFrameSize: options.settings.maxFrameSize || 16384,\n maxConcurrentStreams: options.settings.maxConcurrentStreams || 100,\n maxHeaderListSize: options.settings.maxHeaderListSize,\n maxHeaderSize: options.settings.maxHeaderSize,\n enableConnectProtocol: options.settings.enableConnectProtocol,\n };\n } else {\n serverOptions.settings = {\n enablePush: true,\n initialWindowSize: 65535,\n maxFrameSize: 16384,\n maxConcurrentStreams: 100,\n };\n }\n\n // Create server\n if (this.isSecure) {\n this.server = http2().createSecureServer(serverOptions);\n this.logger.info('HTTP/2 secure server created', 'ServerInit');\n } else {\n this.server = http2().createServer(serverOptions);\n this.logger.info('HTTP/2 server created', 'ServerInit');\n }\n\n // Configure server settings. Socket idle timeout defaults to 30s (its\n // historical hardcode) unless timeouts.idle is set (0 disables).\n this.server.setTimeout(options.limits?.timeouts?.idle ?? 30000);\n if (options.limits?.maxConnections && options.limits.maxConnections > 0) {\n (this.server as any).maxConnections = options.limits.maxConnections;\n }\n\n // Handle streams (HTTP/2 requests). Wrap so the async handler's promise is\n // always caught - a rejection escaping here becomes an unhandled rejection\n // that can crash the process.\n this.server.on('stream', (stream: ServerHttp2Stream, headers: IncomingHttpHeaders) => {\n void this.handleStream(stream, headers).catch(error => {\n this.logger.error('Unhandled HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n\n // Handle session events\n this.server.on('session', session => {\n this.logger.debug('HTTP/2 session created', 'Session');\n\n session.on('error', err => {\n this.logger.error('HTTP/2 session error', 'Session', { error: err.message });\n });\n });\n\n // Handle server errors\n this.server.on('error', err => {\n this.logger.error('HTTP/2 server error', 'ServerError', { error: err.message });\n });\n }\n\n // Configure server for maximum performance\n configurePerformance(\n config: { compression?: { enabled: boolean; threshold?: number }; minimal?: boolean } = {}\n ) {\n if (config.compression !== undefined) {\n this.compressionEnabled = config.compression.enabled;\n if (config.compression.threshold !== undefined) {\n this.compressionThreshold = config.compression.threshold;\n }\n }\n\n if (config.minimal) {\n this.compressionEnabled = false;\n this.compressionThreshold = Infinity;\n }\n }\n\n // Configure request tracking\n setRequestTracking(enabled: boolean): void {\n this.requestTrackingEnabled = enabled;\n }\n\n // Middleware management\n use(middleware: Middleware): void {\n // Defensive check: Don't add MiddlewareInterface objects to globalMiddleware\n // MiddlewareInterface objects should only be handled by MiddlewareManager\n if (\n middleware &&\n typeof middleware === 'object' &&\n (middleware as any).install &&\n (middleware as any).metadata\n ) {\n this.logger?.warn?.(\n `Attempted to add MiddlewareInterface \"${(middleware as any).metadata?.name}\" to HTTP server globalMiddleware. ` +\n `This should be handled by MiddlewareManager instead. Skipping.`,\n 'Middleware'\n );\n return;\n }\n\n this.globalMiddleware.push(middleware);\n }\n\n // Set hooks manager\n setHookManager(hookManager: any): void {\n this.hookManager = hookManager;\n }\n\n // Routing methods\n get(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('GET', path, handlers);\n }\n\n post(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('POST', path, handlers);\n }\n\n put(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PUT', path, handlers);\n }\n\n delete(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('DELETE', path, handlers);\n }\n\n patch(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PATCH', path, handlers);\n }\n\n private addRoute(method: string, path: string, handlers: (Middleware | HttpHandler)[]): void {\n const { pattern, paramNames } = this.pathToRegex(path);\n const handler = handlers.pop() as HttpHandler;\n const middleware = handlers as Middleware[];\n\n const route = {\n method,\n path,\n pattern,\n paramNames,\n handler,\n middleware,\n };\n\n this.routes.push(route);\n\n // Organize routes for optimal lookup\n if (paramNames.length === 0) {\n const staticKey = `${method}:${path}`;\n this.staticRoutes.set(staticKey, route);\n } else {\n this.dynamicRoutes.push(route);\n const segmentCount = PathMatcher.countSegments(path);\n if (!this.routesBySegmentCount.has(segmentCount)) {\n this.routesBySegmentCount.set(segmentCount, []);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.routesBySegmentCount.get(segmentCount)!.push(route);\n }\n }\n\n private pathToRegex(path: string): { pattern: RegExp; paramNames: string[] } {\n const compiled = PathMatcher.compile(path);\n return {\n pattern: compiled.pattern || new RegExp(`^${path.replace(/\\//g, '\\\\/')}$`),\n paramNames: compiled.paramNames,\n };\n }\n\n private async handleStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): Promise<void> {\n this.requestCounter++;\n\n const httpReq = this.createRequestFromStream(stream, headers);\n const httpRes = this.createResponseFromStream(stream, httpReq);\n\n try {\n // Parse URL and query\n const url = (headers[':path'] as string) || '/';\n const queryIndex = url.indexOf('?');\n\n if (queryIndex === -1) {\n httpReq.path = url;\n httpReq.query = {};\n } else {\n httpReq.path = url.substring(0, queryIndex);\n httpReq.query = this.parseQueryString(url.substring(queryIndex + 1));\n }\n\n // Parse body for POST/PUT/PATCH\n const method = httpReq.method;\n if (\n method === MoroHttp2Server.METHOD_POST ||\n method === MoroHttp2Server.METHOD_PUT ||\n method === MoroHttp2Server.METHOD_PATCH\n ) {\n httpReq.body = await this.parseBody(stream, headers);\n }\n\n // Execute hooks\n if (this.hookManager) {\n await this.hookManager.execute('request', {\n request: httpReq,\n response: httpRes,\n });\n\n // Post-response hooks. The HTTP/2 response object is a plain object\n // (no event emitter), so listen on the underlying stream instead.\n if (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('response')) {\n stream.once('close', () => {\n void Promise.resolve(\n this.hookManager.execute('response', { request: httpReq, response: httpRes })\n ).catch((error: any) =>\n this.logger?.error?.(`Response hook error: ${error?.message || error}`, 'Hooks')\n );\n });\n }\n }\n\n // A request hook may answer the request itself (rate limiting, auth\n // rejection). Registration of the response hooks above still stands.\n if (httpRes.headersSent) return;\n\n // Execute global middleware\n if (this.globalMiddleware.length > 0) {\n await this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);\n }\n\n // If middleware handled the request, don't continue\n if (httpRes.headersSent) {\n return;\n }\n\n // Find matching route (path is always set after URL parsing)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const route = this.findRoute(method || MoroHttp2Server.METHOD_GET, httpReq.path!);\n if (!route) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json; charset=utf-8');\n httpRes.setHeader('Content-Length', MoroHttp2Server.RESPONSE_TEMPLATES.notFound.length);\n httpRes.end(MoroHttp2Server.RESPONSE_TEMPLATES.notFound);\n return;\n }\n\n // Extract path parameters\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const matches = httpReq.path!.match(route.pattern);\n if (matches) {\n httpReq.params = this.poolManager.acquireParams();\n const paramNames = route.paramNames;\n for (let i = 0; i < paramNames.length; i++) {\n const paramName = paramNames[i];\n const value = matches[i + 1];\n if (paramName !== undefined && value !== undefined) {\n httpReq.params[paramName] = value;\n }\n }\n }\n\n // Execute route middleware\n if (route.middleware.length > 0) {\n await this.executeMiddleware(route.middleware, httpReq, httpRes);\n }\n\n // Execute handler\n const handlerResult = route.handler(httpReq, httpRes);\n if (handlerResult && typeof handlerResult.then === 'function') {\n await handlerResult;\n }\n } catch (error) {\n this.logger.error('HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n requestId: httpReq.requestId,\n path: httpReq.path,\n });\n\n // Error hooks are observational: fire-and-forget so a slow or throwing\n // observer can never delay or alter the error response.\n if (\n this.hookManager &&\n (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('error'))\n ) {\n void Promise.resolve(\n this.hookManager.execute('error', { request: httpReq, response: httpRes, error })\n ).catch((hookError: any) =>\n this.logger?.error?.(`Error hook error: ${hookError?.message || hookError}`, 'Hooks')\n );\n }\n\n if (!httpRes.headersSent) {\n httpRes.status(500).json({\n success: false,\n error: 'Internal server error',\n requestId: httpReq.requestId,\n });\n }\n } finally {\n // Release pooled objects\n if (httpReq.params && Object.keys(httpReq.params).length === 0) {\n this.poolManager.releaseParams(httpReq.params);\n }\n if (httpReq.query && Object.keys(httpReq.query).length === 0) {\n this.poolManager.releaseQuery(httpReq.query);\n }\n }\n }\n\n private createRequestFromStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): HttpRequest {\n // Extract method from pseudo-header\n const methodRaw = ((headers[':method'] as string) || 'GET').toUpperCase();\n\n // Intern method string for fast comparison\n let method: string;\n switch (methodRaw) {\n case 'POST':\n method = MoroHttp2Server.METHOD_POST;\n break;\n case 'PUT':\n method = MoroHttp2Server.METHOD_PUT;\n break;\n case 'PATCH':\n method = MoroHttp2Server.METHOD_PATCH;\n break;\n case 'GET':\n method = MoroHttp2Server.METHOD_GET;\n break;\n case 'DELETE':\n method = MoroHttp2Server.METHOD_DELETE;\n break;\n case 'HEAD':\n method = MoroHttp2Server.METHOD_HEAD;\n break;\n case 'OPTIONS':\n method = MoroHttp2Server.METHOD_OPTIONS;\n break;\n default:\n method = methodRaw;\n }\n\n // Convert HTTP/2 headers to standard headers (remove pseudo-headers)\n const standardHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (!key.startsWith(':')) {\n standardHeaders[key] = Array.isArray(value) ? value.join(', ') : (value as string);\n }\n }\n\n // Parse cookies\n const cookieHeader = standardHeaders['cookie'];\n const cookies: Record<string, string> = {};\n if (cookieHeader) {\n const cookieParts = cookieHeader.split(';');\n for (const cookie of cookieParts) {\n const equalIndex = cookie.indexOf('=');\n if (equalIndex > 0) {\n const name = cookie.substring(0, equalIndex).trim();\n const value = cookie.substring(equalIndex + 1);\n if (name && value) {\n try {\n cookies[name] = decodeURIComponent(value);\n } catch {\n // Malformed percent-encoding: keep the raw value rather than\n // throwing a URIError. createRequestFromStream runs before\n // handleStream's try block, so an escape here would surface as\n // an unhandled rejection and crash the process.\n cookies[name] = value;\n }\n }\n }\n }\n }\n\n const httpReq: HttpRequest = {\n method,\n path: '',\n url: (headers[':path'] as string) || '/',\n query: {},\n params: {},\n headers: standardHeaders,\n body: null,\n cookies,\n ip: (stream.session?.socket as any)?.remoteAddress || '',\n requestId: this.requestTrackingEnabled ? this.poolManager.generateRequestId() : '',\n httpVersion: '2.0',\n } as HttpRequest;\n\n // Store stream reference for push capability\n (httpReq as any)._http2Stream = stream;\n (httpReq as any)._http2Headers = headers;\n\n return httpReq;\n }\n\n private createResponseFromStream(stream: ServerHttp2Stream, req: HttpRequest): HttpResponse {\n const httpRes: any = {\n statusCode: 200,\n headersSent: false,\n _headers: {} as OutgoingHttpHeaders,\n _stream: stream,\n _req: req,\n _logger: this.logger,\n _poolManager: this.poolManager,\n _compressionEnabled: this.compressionEnabled,\n _compressionThreshold: this.compressionThreshold,\n };\n\n // Status method\n httpRes.status = (code: number) => {\n httpRes.statusCode = code;\n return httpRes;\n };\n\n // Set header\n httpRes.setHeader = (name: string, value: string | string[]) => {\n httpRes._headers[name.toLowerCase()] = value;\n return httpRes;\n };\n\n // Get header\n httpRes.getHeader = (name: string) => {\n return httpRes._headers[name.toLowerCase()];\n };\n\n // Remove header\n httpRes.removeHeader = (name: string) => {\n delete httpRes._headers[name.toLowerCase()];\n return httpRes;\n };\n\n // Has header\n httpRes.hasHeader = (name: string): boolean => {\n return httpRes._headers[name.toLowerCase()] !== undefined;\n };\n\n // Get headers\n httpRes.getHeaders = () => {\n return { ...httpRes._headers };\n };\n\n // JSON response\n httpRes.json = async (data: any) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n const jsonString = JSON.stringify(data);\n const finalBuffer = Buffer.from(jsonString, 'utf8');\n\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n\n // Compression\n if (httpRes._compressionEnabled && finalBuffer.length > httpRes._compressionThreshold) {\n const acceptEncoding = req.headers['accept-encoding'];\n\n if (acceptEncoding && acceptEncoding.includes('gzip')) {\n const compressed = await compressors().gzip(finalBuffer);\n httpRes._headers['content-encoding'] = 'gzip';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n } else if (acceptEncoding && acceptEncoding.includes('deflate')) {\n const compressed = await compressors().deflate(finalBuffer);\n httpRes._headers['content-encoding'] = 'deflate';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n }\n }\n\n httpRes._headers['content-length'] = finalBuffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(finalBuffer);\n httpRes.headersSent = true;\n };\n\n // Send response\n httpRes.send = (data: string | Buffer) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n if (!httpRes._headers['content-type']) {\n if (typeof data === 'string') {\n try {\n JSON.parse(data);\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n } catch {\n httpRes._headers['content-type'] = 'text/plain; charset=utf-8';\n }\n } else {\n httpRes._headers['content-type'] = 'application/octet-stream';\n }\n }\n\n const buffer = typeof data === 'string' ? Buffer.from(data) : data;\n httpRes._headers['content-length'] = buffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(buffer);\n httpRes.headersSent = true;\n };\n\n // End response\n httpRes.end = (data?: any) => {\n if (httpRes.headersSent || stream.destroyed) return httpRes;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(data || '');\n httpRes.headersSent = true;\n return httpRes;\n };\n\n // Standardized response helpers\n httpRes.success = <T = any>(data: T, message?: string) => {\n const response: any = {\n success: true,\n data,\n };\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n httpRes.error = (error: string, code?: string, message?: string) => {\n const response: any = {\n success: false,\n error,\n };\n if (code !== undefined) {\n response.code = code;\n }\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n // Common HTTP error helpers (automatically set status code)\n httpRes.unauthorized = (message: string = 'Authentication required') => {\n httpRes.statusCode = 401;\n httpRes.json({\n success: false,\n error: 'Unauthorized',\n code: 'UNAUTHORIZED',\n message,\n });\n };\n\n httpRes.forbidden = (message: string = 'Insufficient permissions') => {\n httpRes.statusCode = 403;\n httpRes.json({\n success: false,\n error: 'Forbidden',\n code: 'FORBIDDEN',\n message,\n });\n };\n\n httpRes.notFound = (resource: string = 'Resource') => {\n httpRes.statusCode = 404;\n httpRes.json({\n success: false,\n error: 'Not Found',\n code: 'NOT_FOUND',\n message: `${resource} not found`,\n });\n };\n\n httpRes.badRequest = (message: string = 'Invalid request') => {\n httpRes.statusCode = 400;\n httpRes.json({\n success: false,\n error: 'Bad Request',\n code: 'BAD_REQUEST',\n message,\n });\n };\n\n httpRes.conflict = (message: string) => {\n httpRes.statusCode = 409;\n httpRes.json({\n success: false,\n error: 'Conflict',\n code: 'CONFLICT',\n message,\n });\n };\n\n httpRes.internalError = (message: string = 'Internal server error') => {\n httpRes.statusCode = 500;\n httpRes.json({\n success: false,\n error: 'Internal Server Error',\n code: 'INTERNAL_ERROR',\n message,\n });\n };\n\n httpRes.validationError = (\n errors: Array<{ field: string; message: string; code?: string }>\n ) => {\n httpRes.statusCode = 422;\n httpRes.json({\n success: false,\n error: 'Validation Failed',\n code: 'VALIDATION_ERROR',\n errors,\n });\n };\n\n httpRes.rateLimited = (retryAfter?: number) => {\n httpRes.statusCode = 429;\n if (retryAfter) {\n httpRes.setHeader('Retry-After', retryAfter.toString());\n }\n httpRes.json({\n success: false,\n error: 'Rate Limit Exceeded',\n code: 'RATE_LIMITED',\n message: retryAfter\n ? `Too many requests. Retry after ${retryAfter} seconds.`\n : 'Too many requests',\n retryAfter,\n });\n };\n\n // Common success patterns\n httpRes.created = <T = any>(data: T, location?: string) => {\n httpRes.statusCode = 201;\n if (location) {\n httpRes.setHeader('Location', location);\n }\n httpRes.json({\n success: true,\n data,\n });\n };\n\n httpRes.noContent = () => {\n httpRes.statusCode = 204;\n httpRes.end();\n };\n\n httpRes.paginated = <T = any>(\n data: T[],\n pagination: { page: number; limit: number; total: number }\n ) => {\n const totalPages = Math.ceil(pagination.total / pagination.limit);\n httpRes.json({\n success: true,\n data,\n pagination: {\n page: pagination.page,\n limit: pagination.limit,\n total: pagination.total,\n totalPages,\n hasNext: pagination.page < totalPages,\n hasPrev: pagination.page > 1,\n },\n });\n };\n\n // Cookie handling\n httpRes.cookie = (name: string, value: string, options: any = {}) => {\n if (httpRes.headersSent) {\n const isCritical = options.critical || name.includes('session') || name.includes('auth');\n const message = `Cookie '${name}' could not be set - headers already sent`;\n\n if (isCritical || options.throwOnLateSet) {\n throw new Error(`${message}. This may cause authentication or security issues.`);\n } else {\n httpRes._logger.warn(message, 'CookieWarning', { cookieName: name });\n }\n return httpRes;\n }\n\n const cookieValue = encodeURIComponent(value);\n let cookieString = `${name}=${cookieValue}`;\n\n if (options.maxAge) cookieString += `; Max-Age=${options.maxAge}`;\n if (options.expires) cookieString += `; Expires=${options.expires.toUTCString()}`;\n if (options.httpOnly) cookieString += '; HttpOnly';\n if (options.secure) cookieString += '; Secure';\n if (options.sameSite) cookieString += `; SameSite=${options.sameSite}`;\n if (options.domain) cookieString += `; Domain=${options.domain}`;\n if (options.path) cookieString += `; Path=${options.path}`;\n\n const existingCookies = httpRes._headers['set-cookie'] || [];\n const cookies = Array.isArray(existingCookies)\n ? existingCookies\n : [existingCookies as string];\n cookies.push(cookieString);\n httpRes._headers['set-cookie'] = cookies;\n\n return httpRes;\n };\n\n // Clear cookie\n httpRes.clearCookie = (name: string, options: any = {}) => {\n return httpRes.cookie(name, '', {\n expires: new Date(0),\n maxAge: 0,\n ...options,\n });\n };\n\n // Redirect\n httpRes.redirect = (url: string, status: number = 302) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n httpRes.statusCode = status;\n httpRes._headers['location'] = url;\n\n stream.respond({\n ':status': status,\n ...httpRes._headers,\n });\n stream.end();\n httpRes.headersSent = true;\n };\n\n // HTTP/2 Server Push\n httpRes.push = (\n path: string,\n options: { headers?: OutgoingHttpHeaders; priority?: number } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed || !stream.pushAllowed) {\n return null;\n }\n\n try {\n const pushHeaders: any = {\n ':path': path,\n ':method': 'GET',\n ...options.headers,\n };\n\n const pushStream = stream.pushStream(pushHeaders, err => {\n if (err) {\n httpRes._logger.debug('Server push failed', 'ServerPush', {\n path,\n error: err.message,\n });\n }\n });\n\n // Set stream priority if specified\n if (options.priority !== undefined && pushStream) {\n try {\n // Priority weight: 1-256 (default 16)\n // Higher values = higher priority\n const weight = Math.max(1, Math.min(256, options.priority));\n (pushStream as any).priority({\n parent: 0,\n weight,\n exclusive: false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return pushStream;\n } catch (error) {\n httpRes._logger.debug('Server push error', 'ServerPush', {\n path,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n };\n\n // Set stream priority for current response\n httpRes.setPriority = (\n options: { parent?: number; weight?: number; exclusive?: boolean } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed) {\n return httpRes;\n }\n\n try {\n stream.priority({\n parent: options.parent || 0,\n weight: options.weight ? Math.max(1, Math.min(256, options.weight)) : 16,\n exclusive: options.exclusive || false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n return httpRes;\n };\n\n // Set bulk headers\n httpRes.setBulkHeaders = (headers: Record<string, string | number>) => {\n if (httpRes.headersSent) {\n httpRes._logger.warn('Cannot set headers - headers already sent', 'HeaderWarning');\n return httpRes;\n }\n\n for (const key in headers) {\n httpRes._headers[key.toLowerCase()] = String(headers[key]);\n }\n return httpRes;\n };\n\n // Response state\n httpRes.canSetHeaders = (): boolean => {\n return !httpRes.headersSent;\n };\n\n httpRes.getResponseState = () => {\n return {\n headersSent: httpRes.headersSent,\n statusCode: httpRes.statusCode,\n headers: httpRes.getHeaders(),\n finished: stream.destroyed,\n writable: !stream.destroyed,\n };\n };\n\n return httpRes as HttpResponse;\n }\n\n private async parseBody(stream: ServerHttp2Stream, headers: IncomingHttpHeaders): Promise<any> {\n const contentType = (headers['content-type'] as string) || '';\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const contentLength = parseInt((headers['content-length'] as string) || '0');\n\n // Use different limits based on content type\n const isMultipart = contentType.includes('multipart/form-data');\n const maxSize = isMultipart\n ? this.maxUploadSize // Configurable file upload limit (default 100MB)\n : this.maxBodySize; // Configurable body size limit (default 10MB, from server.bodySizeLimit config)\n\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let totalLength = 0;\n\n stream.on('data', (chunk: Buffer) => {\n totalLength += chunk.length;\n if (totalLength > maxSize) {\n const errorMessage = isMultipart\n ? `File upload too large. Maximum ${Math.floor(maxSize / (1024 * 1024))}MB allowed.`\n : 'Request body too large';\n reject(new Error(errorMessage));\n return;\n }\n chunks.push(chunk);\n });\n\n stream.on('end', () => {\n try {\n const body = Buffer.concat(chunks);\n\n if (contentType.includes('application/json')) {\n resolve(JSON.parse(body.toString()));\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n resolve(this.parseUrlEncoded(body.toString()));\n } else if (contentType.includes('multipart/form-data')) {\n resolve(parseMultipartBuffer(body, contentType, this.multipartLimits));\n } else {\n resolve(body.toString());\n }\n } catch (error) {\n reject(error);\n }\n });\n\n stream.on('error', reject);\n });\n }\n\n private parseUrlEncoded(body: string): Record<string, string> {\n const params = new URLSearchParams(body);\n const result: Record<string, string> = {};\n for (const [key, value] of params) {\n result[key] = value;\n }\n return result;\n }\n\n private parseQueryString(queryString: string): Record<string, string> {\n if (!queryString) return {};\n\n const result = this.poolManager.acquireQuery();\n const pairs = queryString.split('&');\n\n for (const pair of pairs) {\n const equalIndex = pair.indexOf('=');\n if (equalIndex === -1) {\n result[decodeURIComponent(pair)] = '';\n } else {\n const key = decodeURIComponent(pair.substring(0, equalIndex));\n const value = decodeURIComponent(pair.substring(equalIndex + 1));\n result[key] = value;\n }\n }\n return result;\n }\n\n private normalizePath(path: string): string {\n if (this.pathNormalizationCache.has(path)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.pathNormalizationCache.get(path)!;\n }\n\n let normalized = path;\n if (normalized.length > 1 && normalized.endsWith('/')) {\n normalized = normalized.slice(0, -1);\n }\n\n if (this.pathNormalizationCache.size < 200) {\n this.pathNormalizationCache.set(path, normalized);\n }\n\n return normalized;\n }\n\n private findRoute(method: string, path: string | undefined): RouteEntry | null {\n // Default to '/' if path is undefined\n const searchPath = path || '/';\n const cacheKey = `${method}:${searchPath}`;\n\n if (this.routeCache.has(cacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(cacheKey)!;\n }\n\n const normalizedPath = this.normalizePath(searchPath);\n const normalizedCacheKey =\n normalizedPath !== searchPath ? `${method}:${normalizedPath}` : cacheKey;\n\n if (normalizedPath !== path && this.routeCache.has(normalizedCacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(normalizedCacheKey)!;\n }\n\n const staticRoute = this.staticRoutes.get(normalizedCacheKey);\n if (staticRoute) {\n this.routeCache.set(normalizedCacheKey, staticRoute);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, staticRoute);\n }\n return staticRoute;\n }\n\n let route: RouteEntry | null = null;\n if (this.dynamicRoutes.length > 0) {\n const segmentCount = PathMatcher.countSegments(normalizedPath);\n const candidateRoutes = this.routesBySegmentCount.get(segmentCount) || this.dynamicRoutes;\n\n for (const candidateRoute of candidateRoutes) {\n if (candidateRoute.method === method && candidateRoute.pattern.test(normalizedPath)) {\n route = candidateRoute;\n break;\n }\n }\n }\n\n if (this.routeCache.size < 500) {\n this.routeCache.set(normalizedCacheKey, route);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, route);\n }\n }\n\n return route;\n }\n\n private async executeMiddleware(\n middleware: Middleware[],\n req: HttpRequest,\n res: HttpResponse\n ): Promise<void> {\n for (const mw of middleware) {\n if (res.headersSent) return;\n\n await new Promise<void>((resolve, reject) => {\n let resolved = false;\n\n const next = () => {\n if (resolved) return;\n resolved = true;\n resolve();\n };\n\n try {\n const result = mw(req, res, next);\n\n if (result && typeof result.then === 'function') {\n (result as Promise<void>)\n .then(() => {\n if (!resolved) next();\n })\n .catch(reject);\n } else if (!resolved) {\n next();\n }\n } catch (error) {\n if (!resolved) {\n resolved = true;\n reject(error);\n }\n }\n });\n }\n }\n\n listen(port: number, callback?: () => void): void;\n listen(port: number, host: string, callback?: () => void): void;\n listen(port: number, host?: string | (() => void), callback?: () => void): void {\n if (typeof host === 'function') {\n callback = host;\n host = undefined;\n }\n\n if (host) {\n this.server.listen(port, host, callback);\n } else {\n this.server.listen(port, callback);\n }\n }\n\n close(): Promise<void> {\n return new Promise(resolve => {\n this.server.close(() => resolve());\n });\n }\n\n forceCleanup(): void {\n this.poolManager.clearAll();\n if (globalThis?.gc) {\n globalThis.gc();\n }\n }\n\n /**\n * Replace the TLS certificate/key for new handshakes (Http2SecureServer is\n * a tls.Server; setSecureContext applies to every later handshake).\n */\n updateSsl(ssl: {\n key: string | Buffer;\n cert: string | Buffer;\n ca?: Array<string | Buffer>;\n passphrase?: string;\n minVersion?: string;\n requestCert?: boolean;\n rejectUnauthorized?: boolean;\n }): void {\n const server = this.server as any;\n if (typeof server.setSecureContext !== 'function') {\n throw new Error('updateSsl: this server was not started with TLS (server.ssl)');\n }\n server.setSecureContext(ssl);\n }\n\n getServer(): Http2Server | Http2SecureServer {\n return this.server;\n }\n\n getPerformanceStats() {\n const poolStats = this.poolManager.getStats();\n return {\n paramObjectPoolSize: poolStats.paramPool.poolSize,\n queryObjectPoolSize: poolStats.queryPool.poolSize,\n headerObjectPoolSize: poolStats.headerPool.poolSize,\n poolManager: poolStats,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"http2-server.js","sourceRoot":"","sources":["../../../src/core/http/http2-server.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,cAAc,IAAI,oBAAoB,GAEvC,MAAM,6BAA6B,CAAC;AAGrC,4EAA4E;AAC5E,2EAA2E;AAC3E,uBAAuB;AACvB,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAEjD,IAAI,QAA4C,CAAC;AACjD,SAAS,KAAK;IACZ,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC,OAAO,CAA2B,CAAC,CAAC;AAC1E,CAAC;AAED,IAAI,IAAoD,CAAC;AACzD,IAAI,OAAuD,CAAC;AAC5D,IAAI,QAA+C,CAAC;AACpD,IAAI,WAAkD,CAAC;AACvD,SAAS,WAAW;IAClB,IAAI,CAAC,IAAI,EAAE,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E,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC5B,IAAI,UAAU,EAAE,EAAE,EAAE,CAAC;YACnB,UAAU,CAAC,EAAE,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,GAQT;QACC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAa,CAAC;QAClC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mBAAmB;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO;YACL,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,oBAAoB,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ;YACnD,WAAW,EAAE,SAAS;SACvB,CAAC;IACJ,CAAC","sourcesContent":["// HTTP/2 Server Implementation for Moro Framework\n//\n// `node:http2` and `node:zlib` are resolved on first use, not at import time.\n// framework.ts imports this module unconditionally (it has to - the HTTP/2\n// branch is chosen at construction), but the vast majority of apps never take\n// that branch. Loading node:http2 eagerly costs every app ~1 MB RSS on top of\n// http/https, and the zlib compressors another ~0.3 MB, for code they never\n// run. Builtins are always synchronously requirable on every supported Node,\n// so this needs no dynamic import and no engines bump.\nimport type {\n Http2Server,\n Http2SecureServer,\n ServerHttp2Stream,\n IncomingHttpHeaders,\n OutgoingHttpHeaders,\n} from 'http2';\nimport { createRequire } from 'module';\nimport { promisify } from 'util';\nimport { createFrameworkLogger } from '../logger/index.js';\nimport {\n HttpRequest,\n HttpResponse,\n Middleware,\n HttpHandler,\n RouteEntry,\n} from '../../types/http.js';\nimport { PathMatcher } from '../routing/path-matcher.js';\nimport { ObjectPoolManager } from '../pooling/object-pool-manager.js';\nimport {\n parseMultipart as parseMultipartBuffer,\n type MultipartLimits,\n} from './utils/multipart-parser.js';\nimport type { HttpRuntimeLimits } from './utils/size.js';\n\n// Builtins only, so the base is irrelevant; 'file:///' keeps this compiling\n// under the CJS transform Jest applies to the test suite (import.meta is a\n// syntax error there).\nconst requireBuiltin = createRequire('file:///');\n\nlet http2Mod: typeof import('http2') | undefined;\nfunction http2(): typeof import('http2') {\n return (http2Mod ??= requireBuiltin('http2') as typeof import('http2'));\n}\n\nlet gzip: ((buf: Buffer) => Promise<Buffer>) | undefined;\nlet deflate: ((buf: Buffer) => Promise<Buffer>) | undefined;\nlet gzipSync: ((buf: Buffer) => Buffer) | undefined;\nlet deflateSync: ((buf: Buffer) => Buffer) | undefined;\nfunction compressors() {\n if (!gzip) {\n const zlib = requireBuiltin('zlib') as typeof import('zlib');\n gzip = promisify(zlib.gzip) as (buf: Buffer) => Promise<Buffer>;\n deflate = promisify(zlib.deflate) as (buf: Buffer) => Promise<Buffer>;\n gzipSync = (buf: Buffer) => zlib.gzipSync(buf);\n deflateSync = (buf: Buffer) => zlib.deflateSync(buf);\n }\n return {\n gzip: gzip,\n deflate: deflate as (buf: Buffer) => Promise<Buffer>,\n gzipSync: gzipSync as (buf: Buffer) => Buffer,\n deflateSync: deflateSync as (buf: Buffer) => Buffer,\n };\n}\n\nexport interface Http2ServerOptions {\n key?: string | Buffer;\n cert?: string | Buffer;\n ca?: string | Buffer | Array<string | Buffer>;\n allowHTTP1?: boolean;\n maxSessionMemory?: number;\n maxBodySize?: number; // Maximum body size for JSON/form data\n maxUploadSize?: number; // Maximum size for file uploads\n /** Flattened runtime limits (timeouts, maxConnections, multipart, ...). */\n limits?: HttpRuntimeLimits;\n settings?: {\n headerTableSize?: number;\n /** Accepted for compatibility but never sent: RFC 9113 forbids a server from advertising ENABLE_PUSH=1 (clients drop the connection), and whether push is possible is the client's setting, read per stream. */\n enablePush?: boolean;\n initialWindowSize?: number;\n maxFrameSize?: number;\n maxConcurrentStreams?: number;\n maxHeaderListSize?: number;\n maxHeaderSize?: number;\n enableConnectProtocol?: boolean;\n };\n}\n\nexport class MoroHttp2Server {\n private server: Http2Server | Http2SecureServer;\n private routes: RouteEntry[] = [];\n private globalMiddleware: Middleware[] = [];\n private compressionEnabled = true;\n private compressionThreshold = 1024;\n // Bodies at or below this size compress on the calling thread; 0 = never\n private compressionMaxInlineBytes = 16384;\n private requestTrackingEnabled = true;\n private multipartLimits?: MultipartLimits;\n private _limits?: HttpRuntimeLimits;\n private logger = createFrameworkLogger('Http2Server');\n private hookManager: any;\n private requestCounter = 0;\n private isSecure: boolean;\n\n // Body size limits - defaults overridden by config in constructor\n private maxBodySize: number = 10 * 1024 * 1024; // Default 10MB (overridden by server.bodySizeLimit config)\n private maxUploadSize: number = 100 * 1024 * 1024; // Default 100MB for file uploads\n\n // Use shared object pool manager\n private poolManager = ObjectPoolManager.getInstance();\n\n // Interned method strings for fast comparison\n private static readonly METHOD_POST = 'POST';\n private static readonly METHOD_PUT = 'PUT';\n private static readonly METHOD_PATCH = 'PATCH';\n private static readonly METHOD_GET = 'GET';\n private static readonly METHOD_DELETE = 'DELETE';\n private static readonly METHOD_HEAD = 'HEAD';\n private static readonly METHOD_OPTIONS = 'OPTIONS';\n\n // Pre-compiled response templates\n private static readonly RESPONSE_TEMPLATES = {\n notFound: Buffer.from('{\"success\":false,\"error\":\"Not found\"}'),\n unauthorized: Buffer.from('{\"success\":false,\"error\":\"Unauthorized\"}'),\n forbidden: Buffer.from('{\"success\":false,\"error\":\"Forbidden\"}'),\n internalError: Buffer.from('{\"success\":false,\"error\":\"Internal server error\"}'),\n methodNotAllowed: Buffer.from('{\"success\":false,\"error\":\"Method not allowed\"}'),\n rateLimited: Buffer.from('{\"success\":false,\"error\":\"Rate limit exceeded\"}'),\n };\n\n // Route optimization structures\n private routeCache = new Map<string, RouteEntry | null>();\n private staticRoutes = new Map<string, RouteEntry>();\n private dynamicRoutes: RouteEntry[] = [];\n private routesBySegmentCount = new Map<number, RouteEntry[]>();\n private pathNormalizationCache = new Map<string, string>();\n\n constructor(options: Http2ServerOptions = {}) {\n this.isSecure = !!(options.key && options.cert);\n\n // Configure body size limits from options\n if (options.maxBodySize) {\n this.maxBodySize = options.maxBodySize;\n }\n if (options.maxUploadSize) {\n this.maxUploadSize = options.maxUploadSize;\n }\n if (options.limits?.multipart) this.multipartLimits = options.limits.multipart;\n if (options.limits) this._limits = options.limits;\n\n const serverOptions: any = {\n allowHTTP1: options.allowHTTP1 !== false,\n ...(options.maxSessionMemory && { maxSessionMemory: options.maxSessionMemory }),\n };\n\n // Add SSL options if secure\n if (this.isSecure) {\n serverOptions.key = options.key;\n serverOptions.cert = options.cert;\n if (options.ca) {\n serverOptions.ca = options.ca;\n }\n }\n\n // Add HTTP/2 settings. SETTINGS_ENABLE_PUSH is never sent: RFC 9113\n // §6.5.2 forbids a server from advertising it as 1, and nghttp2 (curl,\n // Node's own client, browsers) treats that frame as a connection-level\n // PROTOCOL_ERROR - every stream died before its response could be read.\n // Whether push is possible is the CLIENT's setting, read per stream from\n // stream.pushAllowed, so settings.enablePush changes nothing on the wire.\n if (options.settings) {\n serverOptions.settings = {\n headerTableSize: options.settings.headerTableSize,\n initialWindowSize: options.settings.initialWindowSize || 65535,\n maxFrameSize: options.settings.maxFrameSize || 16384,\n maxConcurrentStreams: options.settings.maxConcurrentStreams || 100,\n maxHeaderListSize: options.settings.maxHeaderListSize,\n maxHeaderSize: options.settings.maxHeaderSize,\n enableConnectProtocol: options.settings.enableConnectProtocol,\n };\n } else {\n serverOptions.settings = {\n initialWindowSize: 65535,\n maxFrameSize: 16384,\n maxConcurrentStreams: 100,\n };\n }\n\n // Create server\n if (this.isSecure) {\n this.server = http2().createSecureServer(serverOptions);\n this.logger.info('HTTP/2 secure server created', 'ServerInit');\n } else {\n this.server = http2().createServer(serverOptions);\n this.logger.info('HTTP/2 server created', 'ServerInit');\n }\n\n // Configure server settings. Socket idle timeout defaults to 30s (its\n // historical hardcode) unless timeouts.idle is set (0 disables).\n this.server.setTimeout(options.limits?.timeouts?.idle ?? 30000);\n if (options.limits?.maxConnections && options.limits.maxConnections > 0) {\n (this.server as any).maxConnections = options.limits.maxConnections;\n }\n\n // Handle streams (HTTP/2 requests). Wrap so the async handler's promise is\n // always caught - a rejection escaping here becomes an unhandled rejection\n // that can crash the process.\n this.server.on('stream', (stream: ServerHttp2Stream, headers: IncomingHttpHeaders) => {\n void this.handleStream(stream, headers).catch(error => {\n this.logger.error('Unhandled HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n\n // Handle session events\n this.server.on('session', session => {\n this.logger.debug('HTTP/2 session created', 'Session');\n\n session.on('error', err => {\n this.logger.error('HTTP/2 session error', 'Session', { error: err.message });\n });\n });\n\n // Handle server errors\n this.server.on('error', err => {\n this.logger.error('HTTP/2 server error', 'ServerError', { error: err.message });\n });\n }\n\n // Configure server for maximum performance\n configurePerformance(\n config: {\n compression?: { enabled: boolean; threshold?: number; maxInlineBytes?: number };\n minimal?: boolean;\n } = {}\n ) {\n if (config.compression !== undefined) {\n this.compressionEnabled = config.compression.enabled;\n if (config.compression.threshold !== undefined) {\n this.compressionThreshold = config.compression.threshold;\n }\n if (config.compression.maxInlineBytes !== undefined) {\n this.compressionMaxInlineBytes = config.compression.maxInlineBytes;\n }\n }\n\n if (config.minimal) {\n this.compressionEnabled = false;\n this.compressionThreshold = Infinity;\n }\n }\n\n // Configure request tracking\n setRequestTracking(enabled: boolean): void {\n this.requestTrackingEnabled = enabled;\n }\n\n // Middleware management\n use(middleware: Middleware): void {\n // Defensive check: Don't add MiddlewareInterface objects to globalMiddleware\n // MiddlewareInterface objects should only be handled by MiddlewareManager\n if (\n middleware &&\n typeof middleware === 'object' &&\n (middleware as any).install &&\n (middleware as any).metadata\n ) {\n this.logger?.warn?.(\n `Attempted to add MiddlewareInterface \"${(middleware as any).metadata?.name}\" to HTTP server globalMiddleware. ` +\n `This should be handled by MiddlewareManager instead. Skipping.`,\n 'Middleware'\n );\n return;\n }\n\n this.globalMiddleware.push(middleware);\n }\n\n // Set hooks manager\n setHookManager(hookManager: any): void {\n this.hookManager = hookManager;\n }\n\n // Routing methods\n get(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('GET', path, handlers);\n }\n\n post(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('POST', path, handlers);\n }\n\n put(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PUT', path, handlers);\n }\n\n delete(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('DELETE', path, handlers);\n }\n\n patch(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PATCH', path, handlers);\n }\n\n private addRoute(method: string, path: string, handlers: (Middleware | HttpHandler)[]): void {\n const { pattern, paramNames } = this.pathToRegex(path);\n const handler = handlers.pop() as HttpHandler;\n const middleware = handlers as Middleware[];\n\n const route = {\n method,\n path,\n pattern,\n paramNames,\n handler,\n middleware,\n };\n\n this.routes.push(route);\n\n // Organize routes for optimal lookup\n if (paramNames.length === 0) {\n const staticKey = `${method}:${path}`;\n this.staticRoutes.set(staticKey, route);\n } else {\n this.dynamicRoutes.push(route);\n const segmentCount = PathMatcher.countSegments(path);\n if (!this.routesBySegmentCount.has(segmentCount)) {\n this.routesBySegmentCount.set(segmentCount, []);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.routesBySegmentCount.get(segmentCount)!.push(route);\n }\n }\n\n private pathToRegex(path: string): { pattern: RegExp; paramNames: string[] } {\n const compiled = PathMatcher.compile(path);\n return {\n pattern: compiled.pattern || new RegExp(`^${path.replace(/\\//g, '\\\\/')}$`),\n paramNames: compiled.paramNames,\n };\n }\n\n private async handleStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): Promise<void> {\n this.requestCounter++;\n\n const httpReq = this.createRequestFromStream(stream, headers);\n const httpRes = this.createResponseFromStream(stream, httpReq);\n\n try {\n // Parse URL and query\n const url = (headers[':path'] as string) || '/';\n const queryIndex = url.indexOf('?');\n\n if (queryIndex === -1) {\n httpReq.path = url;\n httpReq.query = {};\n } else {\n httpReq.path = url.substring(0, queryIndex);\n httpReq.query = this.parseQueryString(url.substring(queryIndex + 1));\n }\n\n // Parse body for POST/PUT/PATCH\n const method = httpReq.method;\n if (\n method === MoroHttp2Server.METHOD_POST ||\n method === MoroHttp2Server.METHOD_PUT ||\n method === MoroHttp2Server.METHOD_PATCH\n ) {\n httpReq.body = await this.parseBody(stream, headers);\n }\n\n // Execute hooks\n if (this.hookManager) {\n await this.hookManager.execute('request', {\n request: httpReq,\n response: httpRes,\n });\n\n // Post-response hooks. The HTTP/2 response object is a plain object\n // (no event emitter), so listen on the underlying stream instead.\n if (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('response')) {\n stream.once('close', () => {\n void Promise.resolve(\n this.hookManager.execute('response', { request: httpReq, response: httpRes })\n ).catch((error: any) =>\n this.logger?.error?.(`Response hook error: ${error?.message || error}`, 'Hooks')\n );\n });\n }\n }\n\n // A request hook may answer the request itself (rate limiting, auth\n // rejection). Registration of the response hooks above still stands.\n if (httpRes.headersSent) return;\n\n // Execute global middleware\n if (this.globalMiddleware.length > 0) {\n await this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);\n }\n\n // If middleware handled the request, don't continue\n if (httpRes.headersSent) {\n return;\n }\n\n // Find matching route (path is always set after URL parsing)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const route = this.findRoute(method || MoroHttp2Server.METHOD_GET, httpReq.path!);\n if (!route) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json; charset=utf-8');\n httpRes.setHeader('Content-Length', MoroHttp2Server.RESPONSE_TEMPLATES.notFound.length);\n httpRes.end(MoroHttp2Server.RESPONSE_TEMPLATES.notFound);\n return;\n }\n\n // Extract path parameters\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const matches = httpReq.path!.match(route.pattern);\n if (matches) {\n httpReq.params = this.poolManager.acquireParams();\n const paramNames = route.paramNames;\n for (let i = 0; i < paramNames.length; i++) {\n const paramName = paramNames[i];\n const value = matches[i + 1];\n if (paramName !== undefined && value !== undefined) {\n httpReq.params[paramName] = value;\n }\n }\n }\n\n // Execute route middleware\n if (route.middleware.length > 0) {\n await this.executeMiddleware(route.middleware, httpReq, httpRes);\n }\n\n // Execute handler\n const handlerResult = route.handler(httpReq, httpRes);\n if (handlerResult && typeof handlerResult.then === 'function') {\n await handlerResult;\n }\n } catch (error) {\n this.logger.error('HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n requestId: httpReq.requestId,\n path: httpReq.path,\n });\n\n // Error hooks are observational: fire-and-forget so a slow or throwing\n // observer can never delay or alter the error response.\n if (\n this.hookManager &&\n (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('error'))\n ) {\n void Promise.resolve(\n this.hookManager.execute('error', { request: httpReq, response: httpRes, error })\n ).catch((hookError: any) =>\n this.logger?.error?.(`Error hook error: ${hookError?.message || hookError}`, 'Hooks')\n );\n }\n\n if (!httpRes.headersSent) {\n httpRes.status(500).json({\n success: false,\n error: 'Internal server error',\n requestId: httpReq.requestId,\n });\n }\n } finally {\n // Release pooled objects\n if (httpReq.params && Object.keys(httpReq.params).length === 0) {\n this.poolManager.releaseParams(httpReq.params);\n }\n if (httpReq.query && Object.keys(httpReq.query).length === 0) {\n this.poolManager.releaseQuery(httpReq.query);\n }\n }\n }\n\n private createRequestFromStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): HttpRequest {\n // Extract method from pseudo-header\n const methodRaw = ((headers[':method'] as string) || 'GET').toUpperCase();\n\n // Intern method string for fast comparison\n let method: string;\n switch (methodRaw) {\n case 'POST':\n method = MoroHttp2Server.METHOD_POST;\n break;\n case 'PUT':\n method = MoroHttp2Server.METHOD_PUT;\n break;\n case 'PATCH':\n method = MoroHttp2Server.METHOD_PATCH;\n break;\n case 'GET':\n method = MoroHttp2Server.METHOD_GET;\n break;\n case 'DELETE':\n method = MoroHttp2Server.METHOD_DELETE;\n break;\n case 'HEAD':\n method = MoroHttp2Server.METHOD_HEAD;\n break;\n case 'OPTIONS':\n method = MoroHttp2Server.METHOD_OPTIONS;\n break;\n default:\n method = methodRaw;\n }\n\n // Convert HTTP/2 headers to standard headers (remove pseudo-headers)\n const standardHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (!key.startsWith(':')) {\n standardHeaders[key] = Array.isArray(value) ? value.join(', ') : (value as string);\n }\n }\n\n // Parse cookies\n const cookieHeader = standardHeaders['cookie'];\n const cookies: Record<string, string> = {};\n if (cookieHeader) {\n const cookieParts = cookieHeader.split(';');\n for (const cookie of cookieParts) {\n const equalIndex = cookie.indexOf('=');\n if (equalIndex > 0) {\n const name = cookie.substring(0, equalIndex).trim();\n const value = cookie.substring(equalIndex + 1);\n if (name && value) {\n try {\n cookies[name] = decodeURIComponent(value);\n } catch {\n // Malformed percent-encoding: keep the raw value rather than\n // throwing a URIError. createRequestFromStream runs before\n // handleStream's try block, so an escape here would surface as\n // an unhandled rejection and crash the process.\n cookies[name] = value;\n }\n }\n }\n }\n }\n\n const httpReq: HttpRequest = {\n method,\n path: '',\n url: (headers[':path'] as string) || '/',\n query: {},\n params: {},\n headers: standardHeaders,\n body: null,\n cookies,\n ip: (stream.session?.socket as any)?.remoteAddress || '',\n requestId: this.requestTrackingEnabled ? this.poolManager.generateRequestId() : '',\n httpVersion: '2.0',\n } as HttpRequest;\n\n // Store stream reference for push capability\n (httpReq as any)._http2Stream = stream;\n (httpReq as any)._http2Headers = headers;\n\n return httpReq;\n }\n\n private createResponseFromStream(stream: ServerHttp2Stream, req: HttpRequest): HttpResponse {\n const httpRes: any = {\n statusCode: 200,\n headersSent: false,\n _headers: {} as OutgoingHttpHeaders,\n _stream: stream,\n _req: req,\n _logger: this.logger,\n _poolManager: this.poolManager,\n _compressionEnabled: this.compressionEnabled,\n _compressionThreshold: this.compressionThreshold,\n _compressionMaxInlineBytes: this.compressionMaxInlineBytes,\n };\n\n // Status method\n httpRes.status = (code: number) => {\n httpRes.statusCode = code;\n return httpRes;\n };\n\n // Set header\n httpRes.setHeader = (name: string, value: string | string[]) => {\n httpRes._headers[name.toLowerCase()] = value;\n return httpRes;\n };\n\n // Get header\n httpRes.getHeader = (name: string) => {\n return httpRes._headers[name.toLowerCase()];\n };\n\n // Remove header\n httpRes.removeHeader = (name: string) => {\n delete httpRes._headers[name.toLowerCase()];\n return httpRes;\n };\n\n // Has header\n httpRes.hasHeader = (name: string): boolean => {\n return httpRes._headers[name.toLowerCase()] !== undefined;\n };\n\n // Get headers\n httpRes.getHeaders = () => {\n return { ...httpRes._headers };\n };\n\n // Event surface for middleware written against Node's ServerResponse -\n // the built-in request logger, Prometheus, CloudWatch and performance\n // monitors all call res.on('finish', ...). This response is a plain\n // object, so its events are the stream's: a Duplex emits 'finish' once\n // the body has been flushed and 'close' when the stream is gone, the two\n // events ServerResponse fires. Without these, enabling request logging\n // (the default) turned every HTTP/2 request into a 500.\n httpRes.on = (event: string, listener: (...args: any[]) => void) => {\n stream.on(event, listener);\n return httpRes;\n };\n httpRes.once = (event: string, listener: (...args: any[]) => void) => {\n stream.once(event, listener);\n return httpRes;\n };\n httpRes.off = httpRes.removeListener = (event: string, listener: (...args: any[]) => void) => {\n stream.off(event, listener);\n return httpRes;\n };\n\n // JSON response\n httpRes.json = async (data: any) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n const jsonString = JSON.stringify(data);\n const finalBuffer = Buffer.from(jsonString, 'utf8');\n\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n\n // Compression\n if (httpRes._compressionEnabled && finalBuffer.length > httpRes._compressionThreshold) {\n const acceptEncoding = req.headers['accept-encoding'];\n\n if (acceptEncoding && acceptEncoding.includes('gzip')) {\n // A small body is compressed on this thread (see compressionMaxInlineBytes)\n const compressed =\n httpRes._compressionMaxInlineBytes > 0 &&\n finalBuffer.length <= httpRes._compressionMaxInlineBytes\n ? compressors().gzipSync(finalBuffer)\n : await compressors().gzip(finalBuffer);\n httpRes._headers['content-encoding'] = 'gzip';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n } else if (acceptEncoding && acceptEncoding.includes('deflate')) {\n const compressed =\n httpRes._compressionMaxInlineBytes > 0 &&\n finalBuffer.length <= httpRes._compressionMaxInlineBytes\n ? compressors().deflateSync(finalBuffer)\n : await compressors().deflate(finalBuffer);\n httpRes._headers['content-encoding'] = 'deflate';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n }\n }\n\n httpRes._headers['content-length'] = finalBuffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(finalBuffer);\n httpRes.headersSent = true;\n };\n\n // Send response\n httpRes.send = (data: string | Buffer) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n if (!httpRes._headers['content-type']) {\n // The same sniff the engine and Node servers use: a body that starts\n // with '{' or '[' is JSON, anything else text. Parsing the whole body\n // to decide cost a JSON.parse per response and labelled a bare number\n // or `true` as JSON.\n if (typeof data === 'string') {\n httpRes._headers['content-type'] = /^\\s*[{[]/.test(data)\n ? 'application/json; charset=utf-8'\n : 'text/plain; charset=utf-8';\n } else {\n httpRes._headers['content-type'] = 'application/octet-stream';\n }\n }\n\n const buffer = typeof data === 'string' ? Buffer.from(data) : data;\n httpRes._headers['content-length'] = buffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(buffer);\n httpRes.headersSent = true;\n };\n\n // End response\n httpRes.end = (data?: any) => {\n if (httpRes.headersSent || stream.destroyed) return httpRes;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(data || '');\n httpRes.headersSent = true;\n return httpRes;\n };\n\n // Standardized response helpers\n httpRes.success = <T = any>(data: T, message?: string) => {\n const response: any = {\n success: true,\n data,\n };\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n httpRes.error = (error: string, code?: string, message?: string) => {\n const response: any = {\n success: false,\n error,\n };\n if (code !== undefined) {\n response.code = code;\n }\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n // Common HTTP error helpers (automatically set status code)\n httpRes.unauthorized = (message: string = 'Authentication required') => {\n httpRes.statusCode = 401;\n httpRes.json({\n success: false,\n error: 'Unauthorized',\n code: 'UNAUTHORIZED',\n message,\n });\n };\n\n httpRes.forbidden = (message: string = 'Insufficient permissions') => {\n httpRes.statusCode = 403;\n httpRes.json({\n success: false,\n error: 'Forbidden',\n code: 'FORBIDDEN',\n message,\n });\n };\n\n httpRes.notFound = (resource: string = 'Resource') => {\n httpRes.statusCode = 404;\n httpRes.json({\n success: false,\n error: 'Not Found',\n code: 'NOT_FOUND',\n message: `${resource} not found`,\n });\n };\n\n httpRes.badRequest = (message: string = 'Invalid request') => {\n httpRes.statusCode = 400;\n httpRes.json({\n success: false,\n error: 'Bad Request',\n code: 'BAD_REQUEST',\n message,\n });\n };\n\n httpRes.conflict = (message: string) => {\n httpRes.statusCode = 409;\n httpRes.json({\n success: false,\n error: 'Conflict',\n code: 'CONFLICT',\n message,\n });\n };\n\n httpRes.internalError = (message: string = 'Internal server error') => {\n httpRes.statusCode = 500;\n httpRes.json({\n success: false,\n error: 'Internal Server Error',\n code: 'INTERNAL_ERROR',\n message,\n });\n };\n\n httpRes.validationError = (\n errors: Array<{ field: string; message: string; code?: string }>\n ) => {\n httpRes.statusCode = 422;\n httpRes.json({\n success: false,\n error: 'Validation Failed',\n code: 'VALIDATION_ERROR',\n errors,\n });\n };\n\n httpRes.rateLimited = (retryAfter?: number) => {\n httpRes.statusCode = 429;\n if (retryAfter) {\n httpRes.setHeader('Retry-After', retryAfter.toString());\n }\n httpRes.json({\n success: false,\n error: 'Rate Limit Exceeded',\n code: 'RATE_LIMITED',\n message: retryAfter\n ? `Too many requests. Retry after ${retryAfter} seconds.`\n : 'Too many requests',\n retryAfter,\n });\n };\n\n // Common success patterns\n httpRes.created = <T = any>(data: T, location?: string) => {\n httpRes.statusCode = 201;\n if (location) {\n httpRes.setHeader('Location', location);\n }\n httpRes.json({\n success: true,\n data,\n });\n };\n\n httpRes.noContent = () => {\n httpRes.statusCode = 204;\n httpRes.end();\n };\n\n httpRes.paginated = <T = any>(\n data: T[],\n pagination: { page: number; limit: number; total: number }\n ) => {\n const totalPages = Math.ceil(pagination.total / pagination.limit);\n httpRes.json({\n success: true,\n data,\n pagination: {\n page: pagination.page,\n limit: pagination.limit,\n total: pagination.total,\n totalPages,\n hasNext: pagination.page < totalPages,\n hasPrev: pagination.page > 1,\n },\n });\n };\n\n // Cookie handling\n httpRes.cookie = (name: string, value: string, options: any = {}) => {\n if (httpRes.headersSent) {\n const isCritical = options.critical || name.includes('session') || name.includes('auth');\n const message = `Cookie '${name}' could not be set - headers already sent`;\n\n if (isCritical || options.throwOnLateSet) {\n throw new Error(`${message}. This may cause authentication or security issues.`);\n } else {\n httpRes._logger.warn(message, 'CookieWarning', { cookieName: name });\n }\n return httpRes;\n }\n\n const cookieValue = encodeURIComponent(value);\n let cookieString = `${name}=${cookieValue}`;\n\n if (options.maxAge) cookieString += `; Max-Age=${options.maxAge}`;\n if (options.expires) cookieString += `; Expires=${options.expires.toUTCString()}`;\n if (options.httpOnly) cookieString += '; HttpOnly';\n if (options.secure) cookieString += '; Secure';\n if (options.sameSite) cookieString += `; SameSite=${options.sameSite}`;\n if (options.domain) cookieString += `; Domain=${options.domain}`;\n if (options.path) cookieString += `; Path=${options.path}`;\n\n const existingCookies = httpRes._headers['set-cookie'] || [];\n const cookies = Array.isArray(existingCookies)\n ? existingCookies\n : [existingCookies as string];\n cookies.push(cookieString);\n httpRes._headers['set-cookie'] = cookies;\n\n return httpRes;\n };\n\n // Clear cookie\n httpRes.clearCookie = (name: string, options: any = {}) => {\n return httpRes.cookie(name, '', {\n expires: new Date(0),\n maxAge: 0,\n ...options,\n });\n };\n\n // Redirect\n httpRes.redirect = (url: string, status: number = 302) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n httpRes.statusCode = status;\n httpRes._headers['location'] = url;\n\n stream.respond({\n ':status': status,\n ...httpRes._headers,\n });\n stream.end();\n httpRes.headersSent = true;\n };\n\n // HTTP/2 Server Push\n httpRes.push = (\n path: string,\n options: { headers?: OutgoingHttpHeaders; priority?: number } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed || !stream.pushAllowed) {\n return null;\n }\n\n try {\n const pushHeaders: any = {\n ':path': path,\n ':method': 'GET',\n ...options.headers,\n };\n\n const pushStream = stream.pushStream(pushHeaders, err => {\n if (err) {\n httpRes._logger.debug('Server push failed', 'ServerPush', {\n path,\n error: err.message,\n });\n }\n });\n\n // Set stream priority if specified\n if (options.priority !== undefined && pushStream) {\n try {\n // Priority weight: 1-256 (default 16)\n // Higher values = higher priority\n const weight = Math.max(1, Math.min(256, options.priority));\n (pushStream as any).priority({\n parent: 0,\n weight,\n exclusive: false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return pushStream;\n } catch (error) {\n httpRes._logger.debug('Server push error', 'ServerPush', {\n path,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n };\n\n // Set stream priority for current response\n httpRes.setPriority = (\n options: { parent?: number; weight?: number; exclusive?: boolean } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed) {\n return httpRes;\n }\n\n try {\n stream.priority({\n parent: options.parent || 0,\n weight: options.weight ? Math.max(1, Math.min(256, options.weight)) : 16,\n exclusive: options.exclusive || false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n return httpRes;\n };\n\n // Set bulk headers\n httpRes.setBulkHeaders = (headers: Record<string, string | number>) => {\n if (httpRes.headersSent) {\n httpRes._logger.warn('Cannot set headers - headers already sent', 'HeaderWarning');\n return httpRes;\n }\n\n for (const key in headers) {\n httpRes._headers[key.toLowerCase()] = String(headers[key]);\n }\n return httpRes;\n };\n\n // Response state\n httpRes.canSetHeaders = (): boolean => {\n return !httpRes.headersSent;\n };\n\n httpRes.getResponseState = () => {\n return {\n headersSent: httpRes.headersSent,\n statusCode: httpRes.statusCode,\n headers: httpRes.getHeaders(),\n finished: stream.destroyed,\n writable: !stream.destroyed,\n };\n };\n\n return httpRes as HttpResponse;\n }\n\n private async parseBody(stream: ServerHttp2Stream, headers: IncomingHttpHeaders): Promise<any> {\n const contentType = (headers['content-type'] as string) || '';\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const contentLength = parseInt((headers['content-length'] as string) || '0');\n\n // Use different limits based on content type\n const isMultipart = contentType.includes('multipart/form-data');\n const maxSize = isMultipart\n ? this.maxUploadSize // Configurable file upload limit (default 100MB)\n : this.maxBodySize; // Configurable body size limit (default 10MB, from server.bodySizeLimit config)\n\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let totalLength = 0;\n\n stream.on('data', (chunk: Buffer) => {\n totalLength += chunk.length;\n if (totalLength > maxSize) {\n const errorMessage = isMultipart\n ? `File upload too large. Maximum ${Math.floor(maxSize / (1024 * 1024))}MB allowed.`\n : 'Request body too large';\n reject(new Error(errorMessage));\n return;\n }\n chunks.push(chunk);\n });\n\n stream.on('end', () => {\n try {\n const body = Buffer.concat(chunks);\n\n if (contentType.includes('application/json')) {\n resolve(JSON.parse(body.toString()));\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n resolve(this.parseUrlEncoded(body.toString()));\n } else if (contentType.includes('multipart/form-data')) {\n resolve(parseMultipartBuffer(body, contentType, this.multipartLimits));\n } else {\n resolve(body.toString());\n }\n } catch (error) {\n reject(error);\n }\n });\n\n stream.on('error', reject);\n });\n }\n\n private parseUrlEncoded(body: string): Record<string, string> {\n const params = new URLSearchParams(body);\n const result: Record<string, string> = {};\n for (const [key, value] of params) {\n result[key] = value;\n }\n return result;\n }\n\n private parseQueryString(queryString: string): Record<string, string> {\n if (!queryString) return {};\n\n const result = this.poolManager.acquireQuery();\n const pairs = queryString.split('&');\n\n for (const pair of pairs) {\n const equalIndex = pair.indexOf('=');\n if (equalIndex === -1) {\n result[decodeURIComponent(pair)] = '';\n } else {\n const key = decodeURIComponent(pair.substring(0, equalIndex));\n const value = decodeURIComponent(pair.substring(equalIndex + 1));\n result[key] = value;\n }\n }\n return result;\n }\n\n private normalizePath(path: string): string {\n if (this.pathNormalizationCache.has(path)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.pathNormalizationCache.get(path)!;\n }\n\n let normalized = path;\n if (normalized.length > 1 && normalized.endsWith('/')) {\n normalized = normalized.slice(0, -1);\n }\n\n if (this.pathNormalizationCache.size < 200) {\n this.pathNormalizationCache.set(path, normalized);\n }\n\n return normalized;\n }\n\n private findRoute(method: string, path: string | undefined): RouteEntry | null {\n // Default to '/' if path is undefined\n const searchPath = path || '/';\n const cacheKey = `${method}:${searchPath}`;\n\n if (this.routeCache.has(cacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(cacheKey)!;\n }\n\n const normalizedPath = this.normalizePath(searchPath);\n const normalizedCacheKey =\n normalizedPath !== searchPath ? `${method}:${normalizedPath}` : cacheKey;\n\n if (normalizedPath !== path && this.routeCache.has(normalizedCacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(normalizedCacheKey)!;\n }\n\n const staticRoute = this.staticRoutes.get(normalizedCacheKey);\n if (staticRoute) {\n this.routeCache.set(normalizedCacheKey, staticRoute);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, staticRoute);\n }\n return staticRoute;\n }\n\n let route: RouteEntry | null = null;\n if (this.dynamicRoutes.length > 0) {\n const segmentCount = PathMatcher.countSegments(normalizedPath);\n const candidateRoutes = this.routesBySegmentCount.get(segmentCount) || this.dynamicRoutes;\n\n for (const candidateRoute of candidateRoutes) {\n if (candidateRoute.method === method && candidateRoute.pattern.test(normalizedPath)) {\n route = candidateRoute;\n break;\n }\n }\n }\n\n if (this.routeCache.size < 500) {\n this.routeCache.set(normalizedCacheKey, route);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, route);\n }\n }\n\n return route;\n }\n\n private async executeMiddleware(\n middleware: Middleware[],\n req: HttpRequest,\n res: HttpResponse\n ): Promise<void> {\n for (const mw of middleware) {\n if (res.headersSent) return;\n\n await new Promise<void>((resolve, reject) => {\n let resolved = false;\n\n const next = () => {\n if (resolved) return;\n resolved = true;\n resolve();\n };\n\n try {\n const result = mw(req, res, next);\n\n if (result && typeof result.then === 'function') {\n (result as Promise<void>)\n .then(() => {\n if (!resolved) next();\n })\n .catch(reject);\n } else if (!resolved) {\n next();\n }\n } catch (error) {\n if (!resolved) {\n resolved = true;\n reject(error);\n }\n }\n });\n }\n }\n\n listen(port: number, callback?: () => void): void;\n listen(port: number, host: string, callback?: () => void): void;\n listen(port: number, host?: string | (() => void), callback?: () => void): void {\n if (typeof host === 'function') {\n callback = host;\n host = undefined;\n }\n\n if (host) {\n this.server.listen(port, host, callback);\n } else {\n this.server.listen(port, callback);\n }\n }\n\n close(): Promise<void> {\n return new Promise(resolve => {\n this.server.close(() => resolve());\n });\n }\n\n forceCleanup(): void {\n this.poolManager.clearAll();\n if (globalThis?.gc) {\n globalThis.gc();\n }\n }\n\n /**\n * Replace the TLS certificate/key for new handshakes (Http2SecureServer is\n * a tls.Server; setSecureContext applies to every later handshake).\n */\n updateSsl(ssl: {\n key: string | Buffer;\n cert: string | Buffer;\n ca?: Array<string | Buffer>;\n passphrase?: string;\n minVersion?: string;\n requestCert?: boolean;\n rejectUnauthorized?: boolean;\n }): void {\n const server = this.server as any;\n if (typeof server.setSecureContext !== 'function') {\n throw new Error('updateSsl: this server was not started with TLS (server.ssl)');\n }\n server.setSecureContext(ssl);\n }\n\n getServer(): Http2Server | Http2SecureServer {\n return this.server;\n }\n\n getPerformanceStats() {\n const poolStats = this.poolManager.getStats();\n return {\n paramObjectPoolSize: poolStats.paramPool.poolSize,\n queryObjectPoolSize: poolStats.queryPool.poolSize,\n headerObjectPoolSize: poolStats.headerPool.poolSize,\n poolManager: poolStats,\n };\n }\n}\n"]}
@@ -19,7 +19,7 @@ import { randomUUID } from 'crypto';
19
19
  import { createFrameworkLogger } from '../logger/index.js';
20
20
  import { loadNativeEngine, getNativeEngineLoadErrors, } from '../utilities/package-utils.js';
21
21
  import { parseMultipart as parseMultipartBuffer, } from './utils/multipart-parser.js';
22
- import { resolveCompressionSettings, compressBuffer, isCompressible, negotiateEncoding, } from './utils/compression.js';
22
+ import { resolveCompressionSettings, compressBuffer, compressBufferSync, shouldInline, DEFAULT_MAX_INLINE_BYTES, isCompressible, negotiateEncoding, } from './utils/compression.js';
23
23
  import { bodyIsText } from './utils/body-type.js';
24
24
  import { LazyEventEmitter } from './utils/lazy-event-emitter.js';
25
25
  import { parseRawQueryString as parseUwsQueryString } from './utils/query-parser.js';
@@ -750,6 +750,27 @@ export class EngineResponse extends LazyEventEmitter {
750
750
  this._emitDone();
751
751
  return;
752
752
  }
753
+ // A small body is compressed on this thread: cheaper than the threadpool
754
+ // round trip, and the reply goes out in the same native call an
755
+ // uncompressed one would. A failure sends the body as it is.
756
+ if (shouldInline(bytes, s)) {
757
+ let compressed;
758
+ try {
759
+ compressed = compressBufferSync(body, encoding, s.level);
760
+ }
761
+ catch {
762
+ compressed = undefined;
763
+ }
764
+ if (compressed !== undefined) {
765
+ this.responseHeaders['content-encoding'] = encoding;
766
+ const vary = this.responseHeaders['vary'];
767
+ this.responseHeaders['vary'] = vary ? `${vary}, Accept-Encoding` : 'Accept-Encoding';
768
+ }
769
+ this._server._respond(this._reqId, this.statusCode, this._headersFlat(), compressed ?? body);
770
+ this.headersSent = true;
771
+ this._emitDone();
772
+ return;
773
+ }
753
774
  // Async path: compress, then respond (guarding against an abort that
754
775
  // raced the await - the reqId would be invalid).
755
776
  void compressBuffer(body, encoding, s.level)
@@ -1534,6 +1555,7 @@ export class MoroEngineServer {
1534
1555
  enabled: false,
1535
1556
  threshold: 1024,
1536
1557
  level: 6,
1558
+ maxInlineBytes: DEFAULT_MAX_INLINE_BYTES,
1537
1559
  encodings: ['br', 'gzip', 'deflate'],
1538
1560
  };
1539
1561
  // Set by close(); listen() then registers a fresh native server, because the