blob: 414c5e914eb7c925454cdcbb99ede84bca59849d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
|