Socket
Socket
Sign inDemoInstall

@doctormckay/proxy-agent

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @doctormckay/proxy-agent

An HTTP Agent that connects to an HTTP proxy


Version published
Weekly downloads
21
increased by40%
Maintainers
1
Install size
43.8 kB
Created
Weekly downloads
 

Readme

Source

ProxyAgent

This is a module which simply provides an HTTP(S) Agent which allows for requests/connections to be made through an HTTP(S) proxy.

Usage

ProxyAgent.getAgent(secure[, proxyUrl[, proxyTimeout]])

  • secure - true if this agent will be used for secure (HTTPS) requests, or false if not
  • proxyUrl - The URL to your proxy, or something falsy to just get false returned (indicating no agent)
  • proxyTimeout - The timeout for connecting to the proxy in milliseconds; default 5000 (5 seconds)
const ProxyAgent = require('@doctormckay/proxy-agent');
const HTTPS = require('https');

HTTPS.get({
    "host": "icanhazip.com",
    "port": 443,
    "agent": ProxyAgent.getAgent(true, "http://user:pass@1.2.3.4:12345", 10000)
}, (res) => {
	if (res.statusCode != 200) {
		console.log("HTTP error: " + res.statusCode);
	}
	
	res.on('data', (chunk) => {
		console.log(chunk.toString('utf8'));
	});
}).on('error', (err) => {
	console.log(err);
});

FAQs

Last updated on 04 Jul 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc