Init
This commit is contained in:
32
node_modules/http2-wrapper/source/proxies/h2-over-h2.js
generated
vendored
Normal file
32
node_modules/http2-wrapper/source/proxies/h2-over-h2.js
generated
vendored
Normal file
@ -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;
|
||||
Reference in New Issue
Block a user