Skip to content

Commit

Permalink
support legacy addRequest invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Jun 11, 2019
1 parent ae439aa commit ca24d1a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/network/lib/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,18 @@ export class CombinedAgent {
}

// called by Node.js whenever a new request is made internally
// TODO: need to support legacy invocation? https://github.com/nodejs/node/blob/cb68c04ce1bc4534b2d92bc7319c6ff6dda0180d/lib/_http_agent.js#L148-L155
addRequest(req: http.ClientRequest, options: http.RequestOptions) {
addRequest(req: http.ClientRequest, options: http.RequestOptions, port?: number, localAddress?: string) {
// Legacy API: addRequest(req, host, port, localAddress)
// https://github.com/nodejs/node/blob/cb68c04ce1bc4534b2d92bc7319c6ff6dda0180d/lib/_http_agent.js#L148-L155
if (typeof options === 'string') {
// @ts-ignore
options = {
host: options,
port: port!,
localAddress
}
}

const isHttps = isRequestHttps(options)

if (!options.href) {
Expand Down

0 comments on commit ca24d1a

Please sign in to comment.