https-proxy-agent
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -35,3 +35,3 @@ "use strict"; | ||
const agent_base_1 = require("agent-base"); | ||
const parse_proxy_response_1 = __importDefault(require("./parse-proxy-response")); | ||
const parse_proxy_response_1 = require("./parse-proxy-response"); | ||
const debug = (0, debug_1.default)('https-proxy-agent'); | ||
@@ -111,6 +111,8 @@ /** | ||
} | ||
const proxyResponsePromise = (0, parse_proxy_response_1.default)(socket); | ||
const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket); | ||
socket.write(`${payload}\r\n`); | ||
const { statusCode, buffered } = await proxyResponsePromise; | ||
if (statusCode === 200) { | ||
const { connect, buffered } = await proxyResponsePromise; | ||
req.emit('proxyConnect', connect); | ||
this.emit('proxyConnect', connect, req); | ||
if (connect.statusCode === 200) { | ||
req.once('socket', resume); | ||
@@ -117,0 +119,0 @@ if (opts.secureEndpoint) { |
@@ -35,3 +35,3 @@ "use strict"; | ||
const agent_base_1 = require("agent-base"); | ||
const parse_proxy_response_1 = __importDefault(require("./parse-proxy-response")); | ||
const parse_proxy_response_1 = require("./parse-proxy-response"); | ||
const debug = (0, debug_1.default)('https-proxy-agent'); | ||
@@ -111,6 +111,8 @@ /** | ||
} | ||
const proxyResponsePromise = (0, parse_proxy_response_1.default)(socket); | ||
const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket); | ||
socket.write(`${payload}\r\n`); | ||
const { statusCode, buffered } = await proxyResponsePromise; | ||
if (statusCode === 200) { | ||
const { connect, buffered } = await proxyResponsePromise; | ||
req.emit('proxyConnect', connect); | ||
this.emit('proxyConnect', connect, req); | ||
if (connect.statusCode === 200) { | ||
req.once('socket', resume); | ||
@@ -117,0 +119,0 @@ if (opts.secureEndpoint) { |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { IncomingHttpHeaders } from 'http'; | ||
import { Readable } from 'stream'; | ||
export interface ProxyResponse { | ||
export interface ConnectResponse { | ||
statusCode: number; | ||
statusText: string; | ||
headers: IncomingHttpHeaders; | ||
} | ||
export declare function parseProxyResponse(socket: Readable): Promise<{ | ||
connect: ConnectResponse; | ||
buffered: Buffer; | ||
} | ||
export default function parseProxyResponse(socket: Readable): Promise<ProxyResponse>; | ||
}>; | ||
//# sourceMappingURL=parse-proxy-response.d.ts.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseProxyResponse = void 0; | ||
const debug_1 = __importDefault(require("debug")); | ||
@@ -52,8 +53,39 @@ const debug = (0, debug_1.default)('https-proxy-agent:parse-proxy-response'); | ||
} | ||
const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n')); | ||
const statusCode = +firstLine.split(' ')[1]; | ||
const headerParts = buffered.toString('ascii').split('\r\n'); | ||
const firstLine = headerParts.shift(); | ||
if (!firstLine) { | ||
throw new Error('No header received'); | ||
} | ||
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) { | ||
throw new Error(`Invalid header: "${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', firstLine); | ||
cleanup(); | ||
resolve({ | ||
statusCode, | ||
connect: { | ||
statusCode, | ||
statusText, | ||
headers, | ||
}, | ||
buffered, | ||
@@ -68,3 +100,3 @@ }); | ||
} | ||
exports.default = parseProxyResponse; | ||
exports.parseProxyResponse = parseProxyResponse; | ||
//# sourceMappingURL=parse-proxy-response.js.map |
{ | ||
"name": "https-proxy-agent", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "An HTTP(s) proxy `http.Agent` implementation for HTTPS", | ||
@@ -24,3 +24,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"agent-base": "^7.0.0", | ||
"agent-base": "^7.0.1", | ||
"debug": "4" | ||
@@ -32,3 +32,3 @@ }, | ||
"@types/jest": "^29.5.1", | ||
"@types/node": "^14.18.43", | ||
"@types/node": "^14.18.45", | ||
"async-listen": "^2.1.0", | ||
@@ -39,3 +39,3 @@ "async-retry": "^1.3.3", | ||
"typescript": "^5.0.4", | ||
"proxy": "2.0.0", | ||
"proxy": "2.0.1", | ||
"tsconfig": "0.0.0" | ||
@@ -42,0 +42,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
34504
504
4
Updatedagent-base@^7.0.1