The agent function should take the Connection contructor options as argument (#1332)

This commit is contained in:
Tomas Della Vedova
2020-10-12 10:47:10 +02:00
committed by GitHub
parent ea009da3b6
commit 8ec40547fb
5 changed files with 43 additions and 23 deletions

4
lib/Connection.d.ts vendored
View File

@ -28,9 +28,9 @@ import * as https from 'https'
import * as hpagent from 'hpagent'
import { ConnectionOptions as TlsConnectionOptions } from 'tls'
export declare type agentFn = () => any;
export declare type agentFn = (opts: ConnectionOptions) => any;
interface ConnectionOptions {
export interface ConnectionOptions {
url: URL;
ssl?: TlsConnectionOptions;
id?: string;

View File

@ -53,7 +53,7 @@ class Connection {
}
if (typeof opts.agent === 'function') {
this.agent = opts.agent()
this.agent = opts.agent(opts)
} else if (opts.agent === false) {
this.agent = undefined
} else {