From 83354b2b88218090988dd6e526b0a2505b57e0f1 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 6 Apr 2023 22:18:28 +0200 Subject: Updated 5 files and added 1110 files (automated) --- .../http2-wrapper/source/proxies/h2-over-h2.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js (limited to 'includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js') diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js new file mode 100644 index 0000000..414c5e9 --- /dev/null +++ b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js @@ -0,0 +1,32 @@ +'use strict'; +const {globalAgent} = require('../agent.js'); +const Http2OverHttpX = require('./h2-over-hx.js'); +const getAuthorizationHeaders = require('./get-auth-headers.js'); + +const getStatusCode = stream => new Promise((resolve, reject) => { + stream.once('error', reject); + stream.once('response', headers => { + stream.off('error', reject); + resolve(headers[':status']); + }); +}); + +class Http2OverHttp2 extends Http2OverHttpX { + async _getProxyStream(authority) { + const {proxyOptions} = this; + + const headers = { + ...getAuthorizationHeaders(this), + ...proxyOptions.headers, + ':method': 'CONNECT', + ':authority': authority + }; + + const stream = await globalAgent.request(proxyOptions.url, proxyOptions, headers); + const statusCode = await getStatusCode(stream); + + return [stream, statusCode, '']; + } +} + +module.exports = Http2OverHttp2; -- cgit