Skip to content

Commit 3c91a7e

Browse files
committed
fixup! http2: allow passing FileHandle to respondWithFD
1 parent e9d05d2 commit 3c91a7e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/internal/http2/core.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,13 +2524,10 @@ class ServerHttp2Stream extends Http2Stream {
25242524
this[kState].flags |= STREAM_FLAGS_HAS_TRAILERS;
25252525
}
25262526

2527-
if (typeof fd !== 'number' &&
2528-
!(fd instanceof fsPromisesInternal.FileHandle)) {
2529-
throw new ERR_INVALID_ARG_TYPE('fd', ['number', 'FileHandle'], fd);
2530-
}
2531-
2532-
if (typeof fd !== 'number') // FileHandle
2527+
if (fd instanceof fsPromisesInternal.FileHandle)
25332528
fd = fd.fd;
2529+
else if (typeof fd !== 'number')
2530+
throw new ERR_INVALID_ARG_TYPE('fd', ['number', 'FileHandle'], fd);
25342531

25352532
debugStreamObj(this, 'initiating response from fd');
25362533
this[kUpdateTimer]();

test/parallel/test-http2-respond-file-filehandle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fs.promises.open(fname, 'r').then(common.mustCall((fileHandle) => {
2525
});
2626
});
2727
server.on('close', common.mustCall(() => fileHandle.close()));
28-
server.listen(0, () => {
28+
server.listen(0, common.mustCall(() => {
2929

3030
const client = http2.connect(`http://localhost:${server.address().port}`);
3131
const req = client.request();
@@ -43,5 +43,5 @@ fs.promises.open(fname, 'r').then(common.mustCall((fileHandle) => {
4343
server.close();
4444
}));
4545
req.end();
46-
});
46+
}));
4747
}));

0 commit comments

Comments
 (0)