summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/net.ts
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-06-06 04:29:55 -0600
committerGitHub <noreply@github.com>2023-06-06 12:29:55 +0200
commit42991017e9af59d6a5cb6b523228c62f1c32380e (patch)
tree7b32f2472c28b398717cb8bbb62e9583203ea052 /ext/node/polyfills/net.ts
parent2052ba343c0b222cf638e32f15622a237e423317 (diff)
feat(ext/node): Very basic node:http2 support (#19344)
This commit adds basic support for "node:http2" module. Not all APIs have been yet implemented, but this change already allows to use this module for some basic functions. The "grpc" package is still not working, but it's a good stepping stone. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node/polyfills/net.ts')
-rw-r--r--ext/node/polyfills/net.ts34
1 files changed, 19 insertions, 15 deletions
diff --git a/ext/node/polyfills/net.ts b/ext/node/polyfills/net.ts
index 2c2f5f944..79845adb2 100644
--- a/ext/node/polyfills/net.ts
+++ b/ext/node/polyfills/net.ts
@@ -1834,21 +1834,8 @@ function _onconnection(this: any, err: number, clientHandle?: Handle) {
return;
}
- const socket = new Socket({
- handle: clientHandle,
- allowHalfOpen: self.allowHalfOpen,
- pauseOnCreate: self.pauseOnConnect,
- readable: true,
- writable: true,
- });
-
- // TODO(@bartlomieju): implement noDelay and setKeepAlive
-
- self._connections++;
- socket.server = self;
- socket._server = self;
-
- DTRACE_NET_SERVER_CONNECTION(socket);
+ const socket = self._createSocket(clientHandle);
+ this._connections++;
self.emit("connection", socket);
if (netServerSocketChannel.hasSubscribers) {
@@ -2369,6 +2356,23 @@ export class Server extends EventEmitter {
return !!this._handle;
}
+ _createSocket(clientHandle) {
+ const socket = new Socket({
+ handle: clientHandle,
+ allowHalfOpen: this.allowHalfOpen,
+ pauseOnCreate: this.pauseOnConnect,
+ readable: true,
+ writable: true,
+ });
+
+ // TODO(@bartlomieju): implement noDelay and setKeepAlive
+
+ socket.server = this;
+ socket._server = this;
+
+ DTRACE_NET_SERVER_CONNECTION(socket);
+ }
+
_listen2 = _setupListenHandle;
_emitCloseIfDrained() {