http-proxy-agent
Advanced tools
Comparing version 6.1.0 to 6.1.1
@@ -65,3 +65,9 @@ "use strict"; | ||
} | ||
async connect(req, opts) { | ||
addRequest(req, opts) { | ||
req._header = null; | ||
this.setRequestProps(req, opts); | ||
// @ts-expect-error `addRequest()` isn't defined in `@types/node` | ||
super.addRequest(req, opts); | ||
} | ||
setRequestProps(req, opts) { | ||
const { proxy } = this; | ||
@@ -79,3 +85,2 @@ const protocol = opts.secureEndpoint ? 'https:' : 'http:'; | ||
// Inject the `Proxy-Authorization` header if necessary. | ||
req._header = null; | ||
const headers = typeof this.proxyHeaders === 'function' | ||
@@ -99,12 +104,8 @@ ? this.proxyHeaders() | ||
} | ||
// Create a socket connection to the proxy server. | ||
let socket; | ||
if (this.secureProxy) { | ||
debug('Creating `tls.Socket`: %o', this.connectOpts); | ||
socket = tls.connect(this.connectOpts); | ||
} | ||
async connect(req, opts) { | ||
req._header = null; | ||
if (!req.path.includes('://')) { | ||
this.setRequestProps(req, opts); | ||
} | ||
else { | ||
debug('Creating `net.Socket`: %o', this.connectOpts); | ||
socket = net.connect(this.connectOpts); | ||
} | ||
// At this point, the http ClientRequest's internal `_header` field | ||
@@ -118,3 +119,2 @@ // might have already been set. If this is the case then we'll need | ||
if (req.outputData && req.outputData.length > 0) { | ||
// Node >= 12 | ||
debug('Patching connection write() output buffer with updated header'); | ||
@@ -127,2 +127,12 @@ first = req.outputData[0].data; | ||
} | ||
// Create a socket connection to the proxy server. | ||
let socket; | ||
if (this.secureProxy) { | ||
debug('Creating `tls.Socket`: %o', this.connectOpts); | ||
socket = tls.connect(this.connectOpts); | ||
} | ||
else { | ||
debug('Creating `net.Socket`: %o', this.connectOpts); | ||
socket = net.connect(this.connectOpts); | ||
} | ||
// Wait for the socket's `connect` event, so that this `callback()` | ||
@@ -129,0 +139,0 @@ // function throws instead of the `http` request machinery. This is |
@@ -39,2 +39,4 @@ /// <reference types="node" /> | ||
constructor(proxy: Uri | URL, opts?: HttpProxyAgentOptions<Uri>); | ||
addRequest(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void; | ||
setRequestProps(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void; | ||
connect(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): Promise<net.Socket>; | ||
@@ -41,0 +43,0 @@ } |
@@ -65,3 +65,9 @@ "use strict"; | ||
} | ||
async connect(req, opts) { | ||
addRequest(req, opts) { | ||
req._header = null; | ||
this.setRequestProps(req, opts); | ||
// @ts-expect-error `addRequest()` isn't defined in `@types/node` | ||
super.addRequest(req, opts); | ||
} | ||
setRequestProps(req, opts) { | ||
const { proxy } = this; | ||
@@ -79,3 +85,2 @@ const protocol = opts.secureEndpoint ? 'https:' : 'http:'; | ||
// Inject the `Proxy-Authorization` header if necessary. | ||
req._header = null; | ||
const headers = typeof this.proxyHeaders === 'function' | ||
@@ -99,12 +104,8 @@ ? this.proxyHeaders() | ||
} | ||
// Create a socket connection to the proxy server. | ||
let socket; | ||
if (this.secureProxy) { | ||
debug('Creating `tls.Socket`: %o', this.connectOpts); | ||
socket = tls.connect(this.connectOpts); | ||
} | ||
async connect(req, opts) { | ||
req._header = null; | ||
if (!req.path.includes('://')) { | ||
this.setRequestProps(req, opts); | ||
} | ||
else { | ||
debug('Creating `net.Socket`: %o', this.connectOpts); | ||
socket = net.connect(this.connectOpts); | ||
} | ||
// At this point, the http ClientRequest's internal `_header` field | ||
@@ -118,3 +119,2 @@ // might have already been set. If this is the case then we'll need | ||
if (req.outputData && req.outputData.length > 0) { | ||
// Node >= 12 | ||
debug('Patching connection write() output buffer with updated header'); | ||
@@ -127,2 +127,12 @@ first = req.outputData[0].data; | ||
} | ||
// Create a socket connection to the proxy server. | ||
let socket; | ||
if (this.secureProxy) { | ||
debug('Creating `tls.Socket`: %o', this.connectOpts); | ||
socket = tls.connect(this.connectOpts); | ||
} | ||
else { | ||
debug('Creating `net.Socket`: %o', this.connectOpts); | ||
socket = net.connect(this.connectOpts); | ||
} | ||
// Wait for the socket's `connect` event, so that this `callback()` | ||
@@ -129,0 +139,0 @@ // function throws instead of the `http` request machinery. This is |
{ | ||
"name": "http-proxy-agent", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"description": "An HTTP(s) proxy `http.Agent` implementation for HTTP", | ||
@@ -24,3 +24,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"agent-base": "^7.0.2", | ||
"agent-base": "^7.1.0", | ||
"debug": "^4.3.4" | ||
@@ -32,3 +32,3 @@ }, | ||
"@types/node": "^14.18.45", | ||
"async-listen": "^2.1.0", | ||
"async-listen": "^3.0.0", | ||
"jest": "^29.5.0", | ||
@@ -35,0 +35,0 @@ "ts-jest": "^29.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24870
347
Updatedagent-base@^7.1.0