mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Partially fix node-http.test.ts
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user