Skip to content

Commit a3e171c

Browse files
authored
Add hpagent to proxy section (#1363)
1 parent b38e39a commit a3e171c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,26 @@ got('https://sindresorhus.com', {
17501750
});
17511751
```
17521752
1753+
Otherwise, you can use the [`hpagent`](https://github.com/delvedor/hpagent) package, which keeps the internal sockets alive to be reused.
1754+
1755+
```js
1756+
const got = require('got');
1757+
const {HttpsProxyAgent} = require('hpagent');
1758+
1759+
got('https://sindresorhus.com', {
1760+
agent: {
1761+
https: new HttpsProxyAgent({
1762+
keepAlive: true,
1763+
keepAliveMsecs: 1000,
1764+
maxSockets: 256,
1765+
maxFreeSockets: 256,
1766+
scheduling: 'lifo',
1767+
proxy: 'https://localhost:8080'
1768+
})
1769+
}
1770+
});
1771+
```
1772+
17531773
Alternatively, use [`global-agent`](https://github.com/gajus/global-agent) to configure a global proxy for all HTTP/HTTPS traffic in your program.
17541774
17551775
Read the [`http2-wrapper`](https://github.com/szmarczak/http2-wrapper/#proxy-support) docs to learn about proxying for HTTP/2.

0 commit comments

Comments
 (0)