{"_id":"hpagent","_rev":"4086613","name":"hpagent","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"delvedor","email":""}],"time":{"modified":"2025-12-02T22:11:17.000Z","created":"2020-07-16T15:52:20.649Z","1.2.0":"2022-10-29T14:11:04.868Z","1.1.0":"2022-10-07T10:09:04.689Z","1.0.0":"2022-05-02T16:54:24.763Z","0.1.2":"2021-06-30T08:27:38.069Z","0.1.1":"2020-07-17T14:06:29.445Z","0.1.0":"2020-07-16T15:52:20.649Z"},"users":{},"author":{"name":"Tomas Della Vedova"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"versions":{"1.2.0":{"name":"hpagent","version":"1.2.0","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs","types":"./index.d.ts"},"./*":"./*.js"},"scripts":{"test":"standard && NODE_EXTRA_CA_CERTS=test/fixtures/certs_unit_test.pem ava -v test/*.test.js && NODE_EXTRA_CA_CERTS=test/fixtures/certs_unit_test.pem ./test/hang-socket/runner.sh && tsd","test-ci":"standard && ava -v test/*.test.js && tsd"},"engines":{"node":">=14"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^4.2.0","got":"^11.8.3","needle":"^3.1.0","node-fetch":"^2.6.7","proxy":"^1.0.2","simple-get":"^4.0.1","standard":"^17.0.0","tsd":"^0.24.1"},"gitHead":"96f45f1d40bfbdfd0fcc84cdba056be6e0fb8f4c","_id":"hpagent@1.2.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"shasum":"0ae417895430eb3770c03443456b8d90ca464903","size":7725,"noattachment":false,"key":"/hpagent/-/hpagent-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hpagent/download/hpagent-1.2.0.tgz"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"maintainers":[{"name":"delvedor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_1.2.0_1667052664655_0.8829102317636501"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-10-29T14:11:07.431Z","publish_time":1667052664868,"_cnpm_publish_time":1667052664868},"1.1.0":{"name":"hpagent","version":"1.1.0","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs"},"./*":"./*.js"},"scripts":{"test":"standard && NODE_EXTRA_CA_CERTS=test/fixtures/certs_unit_test.pem ava -v test/*.test.js && tsd","test-ci":"standard && ava -v test/*.test.js && tsd"},"engines":{"node":">=14"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^4.2.0","got":"^11.8.3","needle":"^3.1.0","node-fetch":"^2.6.7","proxy":"^1.0.2","simple-get":"^4.0.1","standard":"^17.0.0","tsd":"^0.24.1"},"gitHead":"4abcb618ca72b4d22588ec4ad146becdd7546429","_id":"hpagent@1.1.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"shasum":"9ff305d6716652bbfe9e300d1865d2c51f284f47","size":7178,"noattachment":false,"key":"/hpagent/-/hpagent-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hpagent/download/hpagent-1.1.0.tgz"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"maintainers":[{"name":"delvedor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_1.1.0_1665137344489_0.7008861478724642"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-10-07T10:09:21.492Z","publish_time":1665137344689,"_cnpm_publish_time":1665137344689},"1.0.0":{"name":"hpagent","version":"1.0.0","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs"},"./*":"./*.js"},"scripts":{"test":"standard && NODE_EXTRA_CA_CERTS=test/fixtures/certs_unit_test.pem ava -v test/*.test.js && tsd","test-ci":"standard && ava -v test/*.test.js && tsd"},"engines":{"node":">=14"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^4.2.0","got":"^11.8.3","needle":"^3.1.0","node-fetch":"^2.6.7","proxy":"^1.0.2","simple-get":"^4.0.1","standard":"^17.0.0","tsd":"^0.20.0"},"gitHead":"bc50f54d4c91db22a3bb4816201d6253dc570951","_id":"hpagent@1.0.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"shasum":"c68f68b3df845687dbdc4896546713ce09cc6bee","size":6572,"noattachment":false,"key":"/hpagent/-/hpagent-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hpagent/download/hpagent-1.0.0.tgz"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"maintainers":[{"name":"delvedor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_1.0.0_1651510464576_0.5007921206038468"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-02T16:55:43.956Z","publish_time":1651510464763,"_cnpm_publish_time":1651510464763},"0.1.2":{"name":"hpagent","version":"0.1.2","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs"},"./":"./"},"scripts":{"test":"standard && ava -v test/*.test.js && tsd"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^3.10.1","got":"^11.5.1","needle":"^2.5.0","node-fetch":"^2.6.0","proxy":"^1.0.2","simple-get":"^4.0.0","standard":"^16.0.1","tsd":"^0.13.1"},"gitHead":"ac3b00dcb12f39e3ae4bd81fa953759e1a40f1c6","_id":"hpagent@0.1.2","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"shasum":"cab39c66d4df2d4377dbd212295d878deb9bdaa9","size":8116,"noattachment":false,"key":"/hpagent/-/hpagent-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/hpagent/download/hpagent-0.1.2.tgz"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"maintainers":[{"name":"delvedor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_0.1.2_1625041657935_0.45337638605946773"},"_hasShrinkwrap":false,"publish_time":1625041658069,"_cnpm_publish_time":1625041658069},"0.1.1":{"name":"hpagent","version":"0.1.1","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs"},"./":"./"},"scripts":{"test":"standard && ava -v test/*.test.js && tsd"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^3.10.1","got":"^11.5.1","needle":"^2.5.0","node-fetch":"^2.6.0","proxy":"^1.0.2","standard":"^14.3.4","tsd":"^0.13.1"},"gitHead":"a6e81b8530d9a7c38f0197851eaf03ed8b3aa9c8","_id":"hpagent@0.1.1","_nodeVersion":"12.18.1","_npmVersion":"6.14.5","dist":{"shasum":"66f67f16e5c7a8b59a068e40c2658c2c749ad5e2","size":7779,"noattachment":false,"key":"/hpagent/-/hpagent-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/hpagent/download/hpagent-0.1.1.tgz"},"maintainers":[{"name":"delvedor","email":""}],"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_0.1.1_1594994789349_0.29469484289132186"},"_hasShrinkwrap":false,"publish_time":1594994789445,"_cnpm_publish_time":1594994789445},"0.1.0":{"name":"hpagent","version":"0.1.0","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs"},"./":"./"},"scripts":{"test":"standard && ava -v test/*.test.js && tsd"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^3.10.1","proxy":"^1.0.2","standard":"^14.3.4","tsd":"^0.13.1"},"gitHead":"8699c01d42cab548ab856196c1d809b6cc349b22","_id":"hpagent@0.1.0","_nodeVersion":"12.18.1","_npmVersion":"6.14.5","dist":{"shasum":"17406d4890d2d23fb52184371c01cba362afbb85","size":6751,"noattachment":false,"key":"/hpagent/-/hpagent-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hpagent/download/hpagent-0.1.0.tgz"},"maintainers":[{"name":"delvedor","email":""}],"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_0.1.0_1594914740499_0.937089905338971"},"_hasShrinkwrap":false,"publish_time":1594914740649,"_cnpm_publish_time":1594914740649}},"readme":"# hpagent\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)  ![build](https://github.com/delvedor/hpagent/workflows/build/badge.svg). ![npm](https://img.shields.io/npm/dm/hpagent)\n\nA ready to use http and https agent for working with proxies that keeps connections alive!\n\n## Install\n\n```\nnpm install hpagent\n```\n\n## Usage\n\nBased on your infrastructure, you should use the http agent or the https agent.\nThe following table will help you picking the right one.\n\n| Type              | Proxy  | Server |\n|-------------------|--------|--------|\n| `HttpProxyAgent`  | HTTP   | HTTP   |\n| `HttpProxyAgent`  | HTTPS  | HTTP   |\n| `HttpsProxyAgent` | HTTP   | HTTPS  |\n| `HttpsProxyAgent` | HTTPS  | HTTPS  |\n\n```js\nconst { HttpProxyAgent, HttpsProxyAgent } = require('hpagent')\n```\n\nOnce you have understood the right agent for your use case, you can instance it. It takes the same parameter of the Node.js core's http(s) agent and an additional `proxy` option, which is the url of your proxy.\n\n```js\nconst http = require('http')\nconst { HttpProxyAgent } = require('hpagent')\n\nconst agent = new HttpProxyAgent({\n  keepAlive: true,\n  keepAliveMsecs: 1000,\n  maxSockets: 256,\n  maxFreeSockets: 256,\n  proxy: 'http://localhost:8080'\n})\n\nhttp.get('http://localhost:9200', { agent })\n    .on('response', console.log)\n    .end()\n```\n\nIf your proxy requires basic authentication, you can configure it in the proxy url:\n\n```js\nconst http = require('http')\nconst { HttpProxyAgent } = require('hpagent')\n\nconst agent = new HttpProxyAgent({\n  keepAlive: true,\n  keepAliveMsecs: 1000,\n  maxSockets: 256,\n  maxFreeSockets: 256,\n  proxy: 'http://user:pwd@localhost:8080'\n})\n\nhttp.get('http://localhost:9200', { agent })\n    .on('response', console.log)\n    .end()\n```\n\nYou can also pass custom options intended only for the proxy CONNECT request with the `proxyConnectOptions` option,\nsuch as headers or `tls.connect()` options:\n\n```js\nconst fs = require('fs')\nconst http = require('http')\nconst { HttpProxyAgent } = require('hpagent')\n\nconst agent = new HttpProxyAgent({\n  keepAlive: true,\n  keepAliveMsecs: 1000,\n  maxSockets: 256,\n  maxFreeSockets: 256,\n  proxy: 'https://localhost:8080',\n  proxyConnectOptions: {\n    headers: {\n      'Proxy-Authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l',\n    },\n    ca: [ fs.readFileSync('custom-proxy-cert.pem') ]\n  }\n})\n\nhttp.get('http://localhost:9200', { agent })\n    .on('response', console.log)\n    .end()\n```\n\n## Integrations\n\nFollowing you can find the list of userland http libraries that are tested with this agent.\n\n### [got](https://github.com/sindresorhus/got)\n\n```js\ngot('http://localhost:9200', {\n  agent: {\n    http: new HttpProxyAgent({\n      keepAlive: true,\n      keepAliveMsecs: 1000,\n      maxSockets: 256,\n      maxFreeSockets: 256,\n      scheduling: 'lifo',\n      proxy: 'http://localhost:8080'\n    })\n  }\n})\n```\n\n### [needle](https://github.com/tomas/needle)\n\n```js\nneedle('get', 'http://localhost:9200', {\n  agent: new HttpProxyAgent({\n    keepAlive: true,\n    keepAliveMsecs: 1000,\n    maxSockets: 256,\n    maxFreeSockets: 256,\n    scheduling: 'lifo',\n    proxy: 'http://localhost:8080'\n  })\n})\n```\n\n### [node-fetch](https://github.com/node-fetch/node-fetch)\n\n```js\nfetch('http://localhost:9200', {\n  agent: new HttpProxyAgent({\n    keepAlive: true,\n    keepAliveMsecs: 1000,\n    maxSockets: 256,\n    maxFreeSockets: 256,\n    scheduling: 'lifo',\n    proxy: 'http://localhost:8080'\n  })\n})\n```\n\n### [simple-get](https://github.com/feross/simple-get)\n\n```js\nsget.concat({\n  url: `http://${server.address().address}:${server.address().port}`,\n  agent: new HttpProxyAgent({\n    keepAlive: true,\n    keepAliveMsecs: 1000,\n    maxSockets: 256,\n    maxFreeSockets: 256,\n    scheduling: 'lifo',\n    proxy: `https://${proxy.address().address}:${proxy.address().port}`\n  })\n}, function (err, response, data) {\n  // handle the response\n})\n```\n\n## License\n\nThis software is licensed under the [MIT](./LICENSE).\n","_attachments":{},"homepage":"https://github.com/delvedor/hpagent#readme","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"license":"MIT"}