CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
README.md71 linesDownload Raw Back to https-proxy-agent
1https-proxy-agent2================3### An HTTP(s) proxy `http.Agent` implementation for HTTPS4 5This module provides an `http.Agent` implementation that connects to a specified6HTTP or HTTPS proxy server, and can be used with the built-in `https` module.7 8Specifically, this `Agent` implementation connects to an intermediary "proxy"9server and issues the [CONNECT HTTP method][CONNECT], which tells the proxy to10open a direct TCP connection to the destination server.11 12Since this agent implements the CONNECT HTTP method, it also works with other13protocols that use this method when connecting over proxies (i.e. WebSockets).14See the "Examples" section below for more.15 16Examples17--------18 19#### `https` module example20 21```ts22import * as https from 'https';23import { HttpsProxyAgent } from 'https-proxy-agent';24 25const agent = new HttpsProxyAgent('http://168.63.76.32:3128');26 27https.get('https://example.com', { agent }, (res) => {28  console.log('"response" event!', res.headers);29  res.pipe(process.stdout);30});31```32 33#### `ws` WebSocket connection example34 35```ts36import WebSocket from 'ws';37import { HttpsProxyAgent } from 'https-proxy-agent';38 39const agent = new HttpsProxyAgent('http://168.63.76.32:3128');40const socket = new WebSocket('ws://echo.websocket.org', { agent });41 42socket.on('open', function () {43  console.log('"open" event!');44  socket.send('hello world');45});46 47socket.on('message', function (data, flags) {48  console.log('"message" event! %j %j', data, flags);49  socket.close();50});51```52 53API54---55 56### new HttpsProxyAgent(proxy: string | URL, options?: HttpsProxyAgentOptions)57 58The `HttpsProxyAgent` class implements an `http.Agent` subclass that connects59to the specified "HTTP(s) proxy server" in order to proxy HTTPS and/or WebSocket60requests. This is achieved by using the [HTTP `CONNECT` method][CONNECT].61 62The `proxy` argument is the URL for the proxy server.63 64The `options` argument accepts the usual `http.Agent` constructor options, and65some additional properties:66 67 * `headers` - Object containing additional headers to send to the proxy server68   in the `CONNECT` request.69 70[CONNECT]: http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_Tunneling71 
basant307/AI_Governance_Project · CoolFace