@@ -2,7 +2,6 @@ import { version } from "../version.ts";
22import https from "node:https" ;
33import http from "node:http" ;
44import qs from "node:querystring" ;
5- import { HttpsProxyAgent } from "npm:https-proxy-agent" ;
65import { RequestTimeoutError } from "./errors.ts" ;
76import { config } from "./config.ts" ;
87import { Buffer } from "node:buffer" ;
@@ -43,7 +42,7 @@ export function getSource() {
4342
4443export function buildUrl (
4544 path : string ,
46- parameters : qs . ParsedUrlQueryInput ,
45+ parameters : qs . ParsedUrlQueryInput
4746) : string {
4847 const clonedParams = { ...parameters } ;
4948 for ( const k in clonedParams ) {
@@ -57,23 +56,13 @@ export function buildUrl(
5756export function execute (
5857 path : string ,
5958 parameters : qs . ParsedUrlQueryInput ,
60- timeout : number ,
59+ timeout : number
6160) : Promise < string > {
6261 const url = buildUrl ( path , {
6362 ...parameters ,
6463 source : getSource ( ) ,
6564 } ) ;
6665
67- // Check if we should use a proxy
68- const urlObj = new URL ( url ) ;
69- const shouldUseProxy = ! config . no_proxy ?. split ( "," ) . some ( ( domain ) =>
70- urlObj . hostname . endsWith ( domain . trim ( ) )
71- ) ;
72-
73- const proxyUrl = shouldUseProxy
74- ? ( urlObj . protocol === "https:" ? config . https_proxy : config . http_proxy )
75- : undefined ;
76-
7766 return new Promise ( ( resolve , reject ) => {
7867 let timer : number ;
7968
@@ -107,18 +96,14 @@ export function execute(
10796 if ( timer ) clearTimeout ( timer ) ;
10897 } ;
10998
110- const options : https . RequestOptions = {
111- timeout : timeout > 0 ? timeout : undefined ,
112- } ;
113-
114- if ( proxyUrl ) {
115- options . agent = new HttpsProxyAgent ( proxyUrl ) ;
116- }
99+ const options =
100+ ( parameters . requestOptions as http . RequestOptions ) ||
101+ config . requestOptions ||
102+ { } ;
117103
118- const req = https . get ( url , options , handleResponse ) . on (
119- "error" ,
120- handleError ,
121- ) ;
104+ const req = https
105+ . get ( url , options , handleResponse )
106+ . on ( "error" , handleError ) ;
122107
123108 if ( timeout > 0 ) {
124109 timer = setTimeout ( ( ) => {
0 commit comments