diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-07-10 13:48:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 13:48:35 +0200 |
commit | 5cda141f2d71e8379a14498db8fa2d997c477a52 (patch) | |
tree | de1c106063739f24a764a9194f93f23f2d1fa70c /ext/node | |
parent | 1edc8693bfc4b75e3bb61fc8dc531bdf569b332d (diff) |
fix(node/http): server use FakeSocket and add end method (#19660)
Fixes #19324
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/http.ts | 13 |
1 files changed, 11 insertions, 2 deletions
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; } |