Init
This commit is contained in:
40
node_modules/http2-wrapper/source/proxies/h2-over-hx.js
generated
vendored
Normal file
40
node_modules/http2-wrapper/source/proxies/h2-over-hx.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
const {Agent} = require('../agent.js');
|
||||
const JSStreamSocket = require('../utils/js-stream-socket.js');
|
||||
const UnexpectedStatusCodeError = require('./unexpected-status-code-error.js');
|
||||
const initialize = require('./initialize.js');
|
||||
|
||||
class Http2OverHttpX extends Agent {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
initialize(this, options.proxyOptions);
|
||||
}
|
||||
|
||||
async createConnection(origin, options) {
|
||||
const authority = `${origin.hostname}:${origin.port || 443}`;
|
||||
|
||||
const [stream, statusCode, statusMessage] = await this._getProxyStream(authority);
|
||||
if (statusCode !== 200) {
|
||||
throw new UnexpectedStatusCodeError(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
if (this.proxyOptions.raw) {
|
||||
options.socket = stream;
|
||||
} else {
|
||||
const socket = new JSStreamSocket(stream);
|
||||
socket.encrypted = false;
|
||||
socket._handle.getpeername = out => {
|
||||
out.family = undefined;
|
||||
out.address = undefined;
|
||||
out.port = undefined;
|
||||
};
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
return super.createConnection(origin, options);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Http2OverHttpX;
|
||||
Reference in New Issue
Block a user