We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 1993394 + f97d2bb commit 7665c66Copy full SHA for 7665c66
src/transports/http/server.ts
@@ -222,9 +222,17 @@ export class HttpStreamTransport extends AbstractTransport {
222
}
223
224
private async readRequestBody(req: IncomingMessage): Promise<any> {
225
+ const maxSize = this._config.maxMessageSize ?? 4 * 1024 * 1024;
226
return new Promise((resolve, reject) => {
227
let body = '';
228
+ let size = 0;
229
req.on('data', (chunk) => {
230
+ size += chunk.length;
231
+ if (size > maxSize) {
232
+ req.destroy();
233
+ reject(new Error(`Request body exceeds maximum size of ${maxSize} bytes`));
234
+ return;
235
+ }
236
body += chunk.toString();
237
});
238
req.on('end', () => {
0 commit comments