mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Node: respondWithFile()'s options can have onError. (#20659)
* respondWithFile()'s `options` can have onError. See the Node document: https://nodejs.org/dist/latest-v8.x/docs/api/http2.html#http2_http2stream_respondwithfile_path_headers_options And also the code: https://github.com/nodejs/node/blob/master/lib/internal/http2/core.js#L1698 * update test
This commit is contained in:
6
types/node/index.d.ts
vendored
6
types/node/index.d.ts
vendored
@@ -6118,6 +6118,10 @@ declare module "http2" {
|
||||
length?: number;
|
||||
}
|
||||
|
||||
export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions {
|
||||
onError?: (err: NodeJS.ErrnoException) => void;
|
||||
}
|
||||
|
||||
export interface Http2Stream extends stream.Duplex {
|
||||
readonly aborted: boolean;
|
||||
readonly destroyed: boolean;
|
||||
@@ -6264,7 +6268,7 @@ declare module "http2" {
|
||||
pushStream(headers: OutgoingHttpHeaders, options?: StreamPriorityOptions, callback?: (pushStream: ServerHttp2Stream) => void): void;
|
||||
respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;
|
||||
respondWithFD(fd: number, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptions): void;
|
||||
respondWithFile(path: string, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptions): void;
|
||||
respondWithFile(path: string, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptionsWithError): void;
|
||||
}
|
||||
|
||||
// Http2Session
|
||||
|
||||
@@ -3286,9 +3286,16 @@ namespace http2_tests {
|
||||
serverHttp2Stream.respondWithFD(0);
|
||||
serverHttp2Stream.respondWithFD(0, headers);
|
||||
serverHttp2Stream.respondWithFD(0, headers, options2);
|
||||
let options3: http2.ServerStreamFileResponseOptionsWithError = {
|
||||
onError: (err: NodeJS.ErrnoException) => {},
|
||||
statCheck: (stats: fs.Stats, headers: http2.IncomingHttpHeaders, statOptions: http2.StatOptions) => {},
|
||||
getTrailers: (trailers: http2.IncomingHttpHeaders) => {},
|
||||
offset: 0,
|
||||
length: 0
|
||||
};
|
||||
serverHttp2Stream.respondWithFile('');
|
||||
serverHttp2Stream.respondWithFile('', headers);
|
||||
serverHttp2Stream.respondWithFile('', headers, options2);
|
||||
serverHttp2Stream.respondWithFile('', headers, options3);
|
||||
}
|
||||
|
||||
// Http2Server / Http2SecureServer
|
||||
|
||||
Reference in New Issue
Block a user