summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js')
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js
new file mode 100644
index 0000000..89a0ac4
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js
@@ -0,0 +1,102 @@
+'use strict';
+const {ERR_HTTP2_NO_SOCKET_MANIPULATION} = require('./errors.js');
+
+/* istanbul ignore file */
+/* https://github.com/nodejs/node/blob/6eec858f34a40ffa489c1ec54bb24da72a28c781/lib/internal/http2/compat.js#L195-L272 */
+
+const proxySocketHandler = {
+ has(stream, property) {
+ // Replaced [kSocket] with .socket
+ const reference = stream.session === undefined ? stream : stream.session.socket;
+ return (property in stream) || (property in reference);
+ },
+
+ get(stream, property) {
+ switch (property) {
+ case 'on':
+ case 'once':
+ case 'end':
+ case 'emit':
+ case 'destroy':
+ return stream[property].bind(stream);
+ case 'writable':
+ case 'destroyed':
+ return stream[property];
+ case 'readable':
+ if (stream.destroyed) {
+ return false;
+ }
+
+ return stream.readable;
+ case 'setTimeout': {
+ const {session} = stream;
+ if (session !== undefined) {
+ return session.setTimeout.bind(session);
+ }
+
+ return stream.setTimeout.bind(stream);
+ }
+
+ case 'write':
+ case 'read':
+ case 'pause':
+ case 'resume':
+ throw new ERR_HTTP2_NO_SOCKET_MANIPULATION();
+ default: {
+ // Replaced [kSocket] with .socket
+ const reference = stream.session === undefined ? stream : stream.session.socket;
+ const value = reference[property];
+
+ return typeof value === 'function' ? value.bind(reference) : value;
+ }
+ }
+ },
+
+ getPrototypeOf(stream) {
+ if (stream.session !== undefined) {
+ // Replaced [kSocket] with .socket
+ return Reflect.getPrototypeOf(stream.session.socket);
+ }
+
+ return Reflect.getPrototypeOf(stream);
+ },
+
+ set(stream, property, value) {
+ switch (property) {
+ case 'writable':
+ case 'readable':
+ case 'destroyed':
+ case 'on':
+ case 'once':
+ case 'end':
+ case 'emit':
+ case 'destroy':
+ stream[property] = value;
+ return true;
+ case 'setTimeout': {
+ const {session} = stream;
+ if (session === undefined) {
+ stream.setTimeout = value;
+ } else {
+ session.setTimeout = value;
+ }
+
+ return true;
+ }
+
+ case 'write':
+ case 'read':
+ case 'pause':
+ case 'resume':
+ throw new ERR_HTTP2_NO_SOCKET_MANIPULATION();
+ default: {
+ // Replaced [kSocket] with .socket
+ const reference = stream.session === undefined ? stream : stream.session.socket;
+ reference[property] = value;
+ return true;
+ }
+ }
+ }
+};
+
+module.exports = proxySocketHandler;