Skip to content

Commit 04d0b91

Browse files
committed
feat(node:http): support for ServerOptions.optimizeEmptyRequests
- See nodejs/node#59778
1 parent c13344f commit 04d0b91

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

types/node/http.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ declare module "http" {
357357
* @since v18.17.0, v20.2.0
358358
*/
359359
rejectNonStandardBodyWrites?: boolean | undefined;
360+
/**
361+
* If set to `true`, requests without `Content-Length` or `Transfer-Encoding`
362+
* headers (indicating no body) will be initialized with an already-ended
363+
* body stream, so they will never emit any stream events (like `'data'` or `'end'`).
364+
* You can use `req.readableEnded` to detect this case.
365+
* @default false
366+
* @since v25.1.0
367+
*/
368+
optimizeEmptyRequests?: boolean | undefined;
360369
}
361370
type RequestListener<
362371
Request extends typeof IncomingMessage = typeof IncomingMessage,

types/node/test/http.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import * as url from "node:url";
4444
request; // $ExpectType IncomingMessage
4545
return true;
4646
},
47+
optimizeEmptyRequests: false,
4748
}, reqListener);
4849

4950
server.close();

0 commit comments

Comments
 (0)