summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit_node/http_test.ts1
-rw-r--r--ext/node/polyfills/http.ts13
2 files changed, 12 insertions, 2 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts
index 2dbada770..baebd4678 100644
--- a/cli/tests/unit_node/http_test.ts
+++ b/cli/tests/unit_node/http_test.ts
@@ -261,6 +261,7 @@ Deno.test("[node/http] non-string buffer response", {
}, async () => {
const promise = deferred<void>();
const server = http.createServer((_, res) => {
+ res.socket!.end();
gzip(
Buffer.from("a".repeat(100), "utf8"),
{},
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index fcc490920..e3419e88b 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -274,7 +274,15 @@ const kError = Symbol("kError");
const kUniqueHeaders = Symbol("kUniqueHeaders");
class FakeSocket extends EventEmitter {
+ constructor(opts = {}) {
+ super();
+ this.remoteAddress = opts.hostname;
+ this.remotePort = opts.port;
+ }
+
setKeepAlive() {}
+
+ end() {}
}
/** ClientRequest represents the http(s) request from the client */
@@ -1331,6 +1339,7 @@ export class ServerResponse extends NodeWritable {
});
this.#readable = readable;
this.#resolve = resolve;
+ this.socket = new FakeSocket();
}
setHeader(name: string, value: string) {
@@ -1446,10 +1455,10 @@ export class IncomingMessageForServer extends NodeReadable {
// url: (new URL(request.url).pathname),
this.url = req.url?.slice(req.url.indexOf("/", 8));
this.method = req.method;
- this.socket = {
+ this.socket = new FakeSocket({
remoteAddress: remoteAddr.hostname,
remotePort: remoteAddr.port,
- };
+ });
this.#req = req;
}