Partially fix node-http.test.ts

This commit is contained in:
Kai Tamkun
2025-02-27 17:14:37 -08:00
parent e38a110dbc
commit cd8a1fb17c
4 changed files with 9 additions and 27 deletions

View File

@@ -1832,7 +1832,7 @@ function onServerResponseClose() {
let OriginalWriteHeadFn, OriginalImplicitHeadFn;
function ServerResponse(req, options) {
if (!new.target) {
if (!(this instanceof ServerResponse)) {
return new ServerResponse(req, options);
}

View File

@@ -27,26 +27,4 @@ function patchEmitter(emitter, prefix) {
oldEmit.apply(emitter, arguments);
};
const req = http.request(options, res => {
patchEmitter(res, "res");
console.log(`STATUS: ${res.statusCode}`);
res.setEncoding("utf8");
});
patchEmitter(req, "req");
req.end().once("close", () => {
setTimeout(() => {
server.close();
}, 1);
});
function patchEmitter(emitter, prefix) {
var oldEmit = emitter.emit;
emitter.emit = function () {
console.log([prefix, arguments[0]]);
oldEmit.apply(emitter, arguments);
};
}
}

View File

@@ -2061,7 +2061,7 @@ it("should work when sending https.request with agent:false", async () => {
await promise;
});
it("client should use chunked encoded if more than one write is called", async () => {
it("client should use chunked encoding if more than one write is called", async () => {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

View File

@@ -32,11 +32,10 @@ const filename = tmpdir.resolve('big');
let count = 0;
const server = http.createServer((req, res) => {
let timeoutId;
assert.strictEqual(req.method, 'POST');
req.pause();
setTimeout(() => {
const timeoutId = setTimeout(() => {
req.resume();
}, 1000);
@@ -55,7 +54,12 @@ const server = http.createServer((req, res) => {
server.listen(0);
server.on('listening', () => {
common.createZeroFilledFile(filename);
// Create a zero-filled file
const fd = fs.openSync(filename, 'w');
fs.ftruncateSync(fd, 10 * 1024 * 1024);
fs.closeSync(fd);
makeRequest();
});