mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Node http2: statCheck() may also return false. (#20692)
* Node http2: statCheck() may also return `false`. https://nodejs.org/dist/latest-v8.x/docs/api/http2.html#http2_http2stream_respondwithfile_path_headers_options says: The options.statCheck function may also be used to cancel the send operation by returning false Related node code: - https://github.com/nodejs/node/blob/master/lib/internal/http2/core.js#L1621 - https://github.com/nodejs/node/blob/master/lib/internal/http2/core.js#L1671 * add tests for returning false from statCheck() * change `void|false` to `void|boolean` * fix lint error
This commit is contained in:
parent
2c1dc4970e
commit
e86a56d0cc
2
types/node/index.d.ts
vendored
2
types/node/index.d.ts
vendored
@ -6112,7 +6112,7 @@ declare module "http2" {
|
||||
}
|
||||
|
||||
export interface ServerStreamFileResponseOptions {
|
||||
statCheck?: (stats: fs.Stats, headers: IncomingHttpHeaders, statOptions: StatOptions) => void;
|
||||
statCheck?: (stats: fs.Stats, headers: IncomingHttpHeaders, statOptions: StatOptions) => void|boolean;
|
||||
getTrailers?: (trailers: IncomingHttpHeaders) => void;
|
||||
offset?: number;
|
||||
length?: number;
|
||||
|
||||
@ -3288,6 +3288,7 @@ namespace http2_tests {
|
||||
serverHttp2Stream.respondWithFD(0);
|
||||
serverHttp2Stream.respondWithFD(0, headers);
|
||||
serverHttp2Stream.respondWithFD(0, headers, options2);
|
||||
serverHttp2Stream.respondWithFD(0, headers, {statCheck: () => false});
|
||||
let options3: http2.ServerStreamFileResponseOptionsWithError = {
|
||||
onError: (err: NodeJS.ErrnoException) => {},
|
||||
statCheck: (stats: fs.Stats, headers: http2.IncomingHttpHeaders, statOptions: http2.StatOptions) => {},
|
||||
@ -3298,6 +3299,7 @@ namespace http2_tests {
|
||||
serverHttp2Stream.respondWithFile('');
|
||||
serverHttp2Stream.respondWithFile('', headers);
|
||||
serverHttp2Stream.respondWithFile('', headers, options3);
|
||||
serverHttp2Stream.respondWithFile('', headers, {statCheck: () => false});
|
||||
}
|
||||
|
||||
// Http2Server / Http2SecureServer
|
||||
|
||||
Loading…
Reference in New Issue
Block a user