Skip to content

Commit

Permalink
feat(TypeScript): agent can now be passed as builder method, rather t…
Browse files Browse the repository at this point in the history
…han agent instance
  • Loading branch information
mitchellwills authored and bcoe committed Oct 8, 2019
1 parent 2cda1de commit c84ddd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// limitations under the License.

import {AbortSignal} from 'abort-controller';
import {Agent} from 'https';
import {Agent} from 'http';
import {URL} from 'url';

// tslint:disable no-any

Expand Down Expand Up @@ -84,7 +85,7 @@ export interface GaxiosOptions {
timeout?: number;
onUploadProgress?: (progressEvent: any) => void;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream';
agent?: Agent;
agent?: Agent | ((parsedUrl: URL) => Agent);
validateStatus?: (status: number) => boolean;
retryConfig?: RetryConfig;
retry?: boolean;
Expand Down
7 changes: 5 additions & 2 deletions src/gaxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// limitations under the License.

import extend from 'extend';
import {Agent} from 'https';
import {Agent} from 'http';
import nodeFetch, {Response as NodeFetchResponse} from 'node-fetch';
import qs from 'querystring';
import stream from 'stream';
Expand Down Expand Up @@ -64,7 +64,10 @@ function loadProxy() {
loadProxy();

export class Gaxios {
private agentCache = new Map<string, Agent>();
private agentCache = new Map<
string,
Agent | ((parsedUrl: url.URL) => Agent)
>();

/**
* Default HTTP options that will be used for every HTTP request.
Expand Down

0 comments on commit c84ddd6

Please sign in to comment.