update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
59
electron/node_modules/https-proxy-agent/dist/parse-proxy-response.js
generated
vendored
59
electron/node_modules/https-proxy-agent/dist/parse-proxy-response.js
generated
vendored
|
|
@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseProxyResponse = void 0;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const debug = debug_1.default('https-proxy-agent:parse-proxy-response');
|
||||
const debug = (0, debug_1.default)('https-proxy-agent:parse-proxy-response');
|
||||
function parseProxyResponse(socket) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// we need to buffer any HTTP traffic that happens with the proxy before we get
|
||||
|
|
@ -23,14 +24,12 @@ function parseProxyResponse(socket) {
|
|||
function cleanup() {
|
||||
socket.removeListener('end', onend);
|
||||
socket.removeListener('error', onerror);
|
||||
socket.removeListener('close', onclose);
|
||||
socket.removeListener('readable', read);
|
||||
}
|
||||
function onclose(err) {
|
||||
debug('onclose had error %o', err);
|
||||
}
|
||||
function onend() {
|
||||
cleanup();
|
||||
debug('onend');
|
||||
reject(new Error('Proxy connection ended before receiving CONNECT response'));
|
||||
}
|
||||
function onerror(err) {
|
||||
cleanup();
|
||||
|
|
@ -48,19 +47,55 @@ function parseProxyResponse(socket) {
|
|||
read();
|
||||
return;
|
||||
}
|
||||
const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
|
||||
const statusCode = +firstLine.split(' ')[1];
|
||||
debug('got proxy server response: %o', firstLine);
|
||||
const headerParts = buffered
|
||||
.slice(0, endOfHeaders)
|
||||
.toString('ascii')
|
||||
.split('\r\n');
|
||||
const firstLine = headerParts.shift();
|
||||
if (!firstLine) {
|
||||
socket.destroy();
|
||||
return reject(new Error('No header received from proxy CONNECT response'));
|
||||
}
|
||||
const firstLineParts = firstLine.split(' ');
|
||||
const statusCode = +firstLineParts[1];
|
||||
const statusText = firstLineParts.slice(2).join(' ');
|
||||
const headers = {};
|
||||
for (const header of headerParts) {
|
||||
if (!header)
|
||||
continue;
|
||||
const firstColon = header.indexOf(':');
|
||||
if (firstColon === -1) {
|
||||
socket.destroy();
|
||||
return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
|
||||
}
|
||||
const key = header.slice(0, firstColon).toLowerCase();
|
||||
const value = header.slice(firstColon + 1).trimStart();
|
||||
const current = headers[key];
|
||||
if (typeof current === 'string') {
|
||||
headers[key] = [current, value];
|
||||
}
|
||||
else if (Array.isArray(current)) {
|
||||
current.push(value);
|
||||
}
|
||||
else {
|
||||
headers[key] = value;
|
||||
}
|
||||
}
|
||||
debug('got proxy server response: %o %o', firstLine, headers);
|
||||
cleanup();
|
||||
resolve({
|
||||
statusCode,
|
||||
buffered
|
||||
connect: {
|
||||
statusCode,
|
||||
statusText,
|
||||
headers,
|
||||
},
|
||||
buffered,
|
||||
});
|
||||
}
|
||||
socket.on('error', onerror);
|
||||
socket.on('close', onclose);
|
||||
socket.on('end', onend);
|
||||
read();
|
||||
});
|
||||
}
|
||||
exports.default = parseProxyResponse;
|
||||
exports.parseProxyResponse = parseProxyResponse;
|
||||
//# sourceMappingURL=parse-proxy-response.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue