Skip to content

Commit

Permalink
step
Browse files Browse the repository at this point in the history
  • Loading branch information
Miniast committed May 11, 2024
1 parent a04bdd2 commit 5dbc46f
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,36 @@ export const alignOptions = (options: any): any => {
"userAgents",
"isJson",
"referer",
"rejectUnauthorized",
];
const deprecatedOptions = ["uri", "qs", "strictSSL", "gzip", "jar", "jsonReviver", "jsonReplacer", "json", "skipEventRequest"].concat(
crawlerOnlyOptions
);
const defaultagent = {
https: new HttpsProxyAgent({ proxy: options["proxy"] }),
http: new HttpProxyAgent({ proxy: options["proxy"] }),
};
const gotOptions = {
...options,
url: options.url ?? options.uri,
searchParams: options.qs,
rejectUnauthorized: options.strictSSL,
decompress: options.gzip,
parseJson: options.jsonReviver,
stringifyJson: options.jsonReplacer,
searchParams: options.searchParams ?? options.qs,
decompress: options.decompress ?? options.gzip,
parseJson: options.parseJson ?? options.jsonReviver,
stringifyJson: options.stringifyJson ?? options.jsonReplacer,
timeout: { request: options.timeout },
};

options.rejectUnauthorized = options.rejectUnauthorized ?? options.strictSSL;
if (options.rejectUnauthorized !== undefined) {
if (gotOptions.https === undefined) {
gotOptions.https = { rejectUnauthorized: options.rejectUnauthorized }
}
else {
gotOptions.https.rejectUnauthorized = options.rejectUnauthorized;
}
}

const defaultagent = {
https: new HttpsProxyAgent({ proxy: options["proxy"] }),
http: new HttpProxyAgent({ proxy: options["proxy"] }),
};

// http2 proxy
if (options.http2 === true && options.proxy) {
const { proxies: Http2Proxies } = http2Wrapper;
Expand Down Expand Up @@ -110,5 +121,6 @@ export const alignOptions = (options: any): any => {
}

gotOptions.retry = { limit: 0 };
console.log(gotOptions)
return gotOptions;
};

0 comments on commit 5dbc46f

Please sign in to comment.