Skip to content

Commit

Permalink
Revert migration to hpagent
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Aug 19, 2021
1 parent 05b47c5 commit f0fb017
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"dependencies": {
"got-cjs": "12.0.0-beta.4",
"header-generator": "^1.1.0",
"hpagent": "^0.1.2",
"http-proxy-agent": "^4.0.1",
"http2-wrapper": "^2.1.3",
"https-proxy-agent": "^5.0.0",
"ow": "^0.23.0",
"quick-lru": "^5.1.1"
},
Expand Down
11 changes: 6 additions & 5 deletions src/hooks/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';
import { URL } from 'url';
import { proxies, auto } from 'http2-wrapper';
import { HttpsProxyAgent, HttpProxyAgent } from 'hpagent';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { HttpProxyAgent } from 'http-proxy-agent';
import QuickLRU from 'quick-lru';
import { Options } from 'got-cjs';
import { TransformHeadersAgent } from '../agent/transform-headers-agent';
Expand Down Expand Up @@ -110,15 +111,15 @@ async function getAgents(parsedProxyUrl: URL, rejectUnauthorized: boolean) {
};
} else {
agent = {
http: fixAgent(new HttpsProxyAgent({ proxy: proxyUrl })),
https: fixAgent(new HttpsProxyAgent({ proxy: proxyUrl })),
http: fixAgent(new HttpsProxyAgent(proxyUrl.href)),
https: fixAgent(new HttpsProxyAgent(proxyUrl.href)),
http2: new Http2OverHttps(proxy),
};
}
} else {
agent = {
http: fixAgent(new HttpProxyAgent({ proxy: proxyUrl })),
https: fixAgent(new HttpsProxyAgent({ proxy: proxyUrl })),
http: fixAgent(new HttpProxyAgent(proxyUrl.href)),
https: fixAgent(new HttpsProxyAgent(proxyUrl.href)),
http2: new Http2OverHttp(proxy),
};
}
Expand Down
6 changes: 2 additions & 4 deletions test/proxy.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { URL } from 'url';
import http2 from 'http2-wrapper';
import {
HttpsProxyAgent,
HttpProxyAgent,
} from 'hpagent';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { HttpProxyAgent } from 'http-proxy-agent';

import { proxyHook, agentCache } from '../src/hooks/proxy';
import { TransformHeadersAgent } from '../src/agent/transform-headers-agent';
Expand Down

0 comments on commit f0fb017

Please sign in to comment.