http-proxy-agent
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
agent-base | 7.1.1 | 30.52 kB | MIT | prod | |
debug | 4.3.4 | 12.94 kB | MIT | prod |
The "http-proxy-agent" is an http.Agent
implementation for HTTP that facilitates connection to a specified HTTP or HTTPS proxy server. Its primary function is to enable proxying for HTTP requests, thus serving as a swift, effective strategy for managing HTTP requests in a web application. You can use this module with the built-in http
module.
To use "http-proxy-agent," you need first to import the required modules. In this scenario, you need to import the "http" module and the "HttpProxyAgent" object from the "http-proxy-agent" module. Next, you instantiate the "HttpProxyAgent" class with the URL of the proxy server. You then call the "http.get" method and pass the URL of the website you wish to connect to, sending the "agent" object as an option. After this, you receive a callback function that logs the response headers and pipes the response to stdout. Here is an example usage:
import * as http from 'http';
import { HttpProxyAgent } from 'http-proxy-agent';
const agent = new HttpProxyAgent('http://168.63.76.32:3128');
http.get('http://nodejs.org/api/', { agent }, (res) => {
console.log('"response" event!', res.headers);
res.pipe(process.stdout);
});
It is important to note that the "http-proxy-agent" also accepts usual "http.Agent" constructor options and some additional properties, like the "headers" object.
The documents for "http-proxy-agent" are not explicitly specified in the repository README. However, the GitHub page at "https://github.com/TooTallNate/proxy-agents" provides crucial information about the usage and capabilities of this module. If further documentation is needed, it may be best to reach out to the repository owners or contributors directly.