You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

better-http-proxy-agent

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-http-proxy-agent

An agent for HTTP through an HTTP(S) proxy server


Version published
Maintainers
1
Created

Readme

Source

better-http-proxy-agent

An agent for HTTP through an HTTP(S) proxy server.

This is based on http-proxy-agent but instead of building on a custom base class it extends the NodeJS http.Agent or https.Agent to leverage core functionality such as connection pooling (all connections are to the proxy so there is just one bucket in the pool) and TLS session resumption.

Basic usage

npm install better-http-proxy-agent
const { createAgent } = require('better-http-proxy-agent');
const fs = require('fs');
const http = require('http');

/*
 * Options suitable for the base `http(s).Agent`.
 */
const agentOptions = {
    keepAlive: true,
    timeout: 55000, // for keepAlive
    maxSockets: 100,
    maxFreeSockets: 10,
    maxCachedSessions: 200
};

/*
 * Options suitable for `http(s).request`/`net.connect`/`tls.connect`. These
 * are used to connect to the proxy server.
 *
 * You should provide the `host` and `port` of the proxy here (unless you want
 * the default `localhost`).
 *
 * `protocol` will default to `http:`. If you need to connect to the proxy over
 * HTTPS, set `protocol` to `https:`. `http.Agent` or `https.Agent` will be
 * used accordingly.
 *
 * You can provide `auth` here, which will produce a `Proxy-Authorization`
 * header.
 */
const connectionOptions = {
    protocol: "https:",
    host: "proxy.example.com",
    port: 3128,
    timeout: 5000, // for in-flight requests
    cert: fs.readFileSync("proxy_auth_cert.pem"),
    key: fs.readFileSync("proxy_auth_key.pem"),
    passphrase: "secret"
};

const agent = createAgent(agentOptions, connectionOptions);

http.get("http://www.example.com/", {
    agent
});

Licence

MIT.

Keywords

FAQs

Package last updated on 27 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc