Template Upload

This commit is contained in:
SOUTHERNCO\x2mjbyrn
2017-05-17 13:45:25 -04:00
parent 415b9c25f3
commit 7efe7605b8
11476 changed files with 2170865 additions and 34 deletions

2
node_modules/https-proxy-agent/.npmignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
/node_modules
/?.js

8
node_modules/https-proxy-agent/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,8 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
before_install:
- '[ "${TRAVIS_NODE_VERSION}" != "0.8" ] || npm install -g npm@1.4.28'
- npm install -g npm@latest

90
node_modules/https-proxy-agent/History.md generated vendored Normal file
View File

@ -0,0 +1,90 @@
1.0.0 / 2015-07-10
==================
* upgrade to "agent-base" v2 API
* test: test case is fixed
* use %o debug() formatter
* README: use SVG for Travis-CI badge
0.3.6 / 2015-07-06
==================
* package: update "extend" to v3
* package: update "mocha" to v2
* package: update "debug" to v2
* travis: test node v0.8, v0.10, and v0.12
* test: use ssl-cert-snakeoil self-signed SSL certs
0.3.5 / 2014-06-11
==================
* package: update "debug" to v1.0.0
0.3.4 / 2014-04-09
==================
* gitignore: ignore root level ?.js files
* package: update outdated dependencies
0.3.3 / 2014-01-13
==================
* https-proxy-agnet: use debug() instead of console.error()
* https-proxy-agent: fix debug() call
* History: fix whitespace
0.3.2 / 2013-11-18
==================
* https-proxy-agent: allow "https" without trailing colon
* README: fix typo
0.3.1 / 2013-11-16
==================
* test: enable the HTTPS over HTTPS test on node v0.11.8
* https-proxy-agent: create the proxy socket connection first
* https-proxy-agent: delete `pathname` from the proxy opts as well
* https-proxy-agent: remove dead "end"-emitting code
0.3.0 / 2013-09-16
==================
* https-proxy-agent: use "debug" module
* https-proxy-agent: update to the "agent-base" v1 API
* https-proxy-agent: default the "port" to 443 if not set
* https-proxy-agent: augment the `opts` object for the `tls.connect` function
* https-proxy-agent: use "extend" module
* https-proxy-agent: remove use of `this` as much as possible
* https-proxy-agent: listen for the "error" event of the socket
* test: refactor of tests to use "proxy" module
* test: add "error" event catching test
* test: add 407 proxy response test
* test: use "semver" module, disable the HTTPS over HTTPS test for node >= v0.11.3
0.2.0 / 2013-09-03
==================
* Add initial "Proxy-Authorization" Basic authentication support
0.1.0 / 2013-07-21
==================
* rename `secure` to `secureProxy`
* added `secureEndpoint` option
* various optimizations
* README improvements
0.0.2 / 2013-07-11
==================
* test: add mocha tests
* don't use `socket.ondata`, use the official API instead
* throw an Error when no proxy info is given
* add support for passing options to net/tls .connect()
0.0.1 / 2013-07-09
==================
* Initial release

141
node_modules/https-proxy-agent/README.md generated vendored Normal file
View File

@ -0,0 +1,141 @@
https-proxy-agent
================
### An HTTP(s) proxy `http.Agent` implementation for HTTPS
[![Build Status](https://travis-ci.org/TooTallNate/node-https-proxy-agent.svg?branch=master)](https://travis-ci.org/TooTallNate/node-https-proxy-agent)
This module provides an `http.Agent` implementation that connects to a specified
HTTP or HTTPS proxy server, and can be used with the built-in `https` module.
Specifically, this `Agent` implementation connects to an intermediary "proxy"
server and issues the [CONNECT HTTP method][CONNECT], which tells the proxy to
open a direct TCP connection to the destination server.
Since this agent implements the CONNECT HTTP method, it also works with other
protocols that use this method when connecting over proxies (i.e. WebSockets).
See the "Examples" section below for more.
Installation
------------
Install with `npm`:
``` bash
$ npm install https-proxy-agent
```
Examples
--------
#### `https` module example
``` js
var url = require('url');
var https = require('https');
var HttpsProxyAgent = require('https-proxy-agent');
// HTTP/HTTPS proxy to connect to
var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
console.log('using proxy server %j', proxy);
// HTTPS endpoint for the proxy to connect to
var endpoint = process.argv[2] || 'https://graph.facebook.com/tootallnate';
console.log('attempting to GET %j', endpoint);
var opts = url.parse(endpoint);
// create an instance of the `HttpsProxyAgent` class with the proxy server information
var agent = new HttpsProxyAgent(proxy);
opts.agent = agent;
https.get(opts, function (res) {
console.log('"response" event!', res.headers);
res.pipe(process.stdout);
});
```
#### `ws` WebSocket connection example
``` js
var url = require('url');
var WebSocket = require('ws');
var HttpsProxyAgent = require('https-proxy-agent');
// HTTP/HTTPS proxy to connect to
var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
console.log('using proxy server %j', proxy);
// WebSocket endpoint for the proxy to connect to
var endpoint = process.argv[2] || 'ws://echo.websocket.org';
var parsed = url.parse(endpoint);
console.log('attempting to connect to WebSocket %j', endpoint);
// create an instance of the `HttpsProxyAgent` class with the proxy server information
var opts = url.parse(proxy);
// IMPORTANT! Set the `secureEndpoint` option to `false` when connecting
// over "ws://", but `true` when connecting over "wss://"
opts.secureEndpoint = parsed.protocol ? parsed.protocol == 'wss:' : false;
var agent = new HttpsProxyAgent(opts);
// finally, initiate the WebSocket connection
var socket = new WebSocket(endpoint, { agent: agent });
socket.on('open', function () {
console.log('"open" event!');
socket.send('hello world');
});
socket.on('message', function (data, flags) {
console.log('"message" event! %j %j', data, flags);
socket.close();
});
```
API
---
### new HttpsProxyAgent(opts)
The `HttpsProxyAgent` class implements an `http.Agent` subclass that connects
to the specified "HTTP(s) proxy server" in order to proxy HTTPS and/or WebSocket
requests. This is achieved by using the [HTTP `CONNECT` method][CONNECT].
The `opts` argument may either be a string URI of the proxy server to use, or an
"options" object with more specific properties:
* `host` - String - Proxy host to connect to (may use `hostname` as well). Required.
* `port` - Number - Proxy port to connect to. Required.
* `secureProxy` - Boolean - If `true`, then use TLS to connect to the proxy. Defaults to `false`.
* `secureEndpoint` - Boolean - If `true` then a TLS connection to the endpoint will be established on top of the proxy socket. Defaults to `true`.
* Any other options given are passed to the `net.connect()`/`tls.connect()` functions.
License
-------
(The MIT License)
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[CONNECT]: http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_Tunneling

202
node_modules/https-proxy-agent/https-proxy-agent.js generated vendored Normal file
View File

@ -0,0 +1,202 @@
/**
* Module dependencies.
*/
var net = require('net');
var tls = require('tls');
var url = require('url');
var extend = require('extend');
var Agent = require('agent-base');
var inherits = require('util').inherits;
var debug = require('debug')('https-proxy-agent');
/**
* Module exports.
*/
module.exports = HttpsProxyAgent;
/**
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to the
* specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
*
* @api public
*/
function HttpsProxyAgent (opts) {
if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
if ('string' == typeof opts) opts = url.parse(opts);
if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
debug('creating new HttpsProxyAgent instance: %o', opts);
Agent.call(this, connect);
var proxy = extend({}, opts);
// if `true`, then connect to the proxy server over TLS. defaults to `false`.
this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;
// prefer `hostname` over `host`, and set the `port` if needed
proxy.host = proxy.hostname || proxy.host;
proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);
if (proxy.host && proxy.path) {
// if both a `host` and `path` are specified then it's most likely the
// result of a `url.parse()` call... we need to remove the `path` portion so
// that `net.connect()` doesn't attempt to open that as a unix socket file.
delete proxy.path;
delete proxy.pathname;
}
this.proxy = proxy;
}
inherits(HttpsProxyAgent, Agent);
/**
* Called when the node-core HTTP client library is creating a new HTTP request.
*
* @api public
*/
function connect (req, opts, fn) {
var proxy = this.proxy;
// create a socket connection to the proxy server
var socket;
if (this.secureProxy) {
socket = tls.connect(proxy);
} else {
socket = net.connect(proxy);
}
// we need to buffer any HTTP traffic that happens with the proxy before we get
// the CONNECT response, so that if the response is anything other than an "200"
// response code, then we can re-play the "data" events on the socket once the
// HTTP parser is hooked up...
var buffers = [];
var buffersLength = 0;
function read () {
var b = socket.read();
if (b) ondata(b);
else socket.once('readable', read);
}
function cleanup () {
socket.removeListener('data', ondata);
socket.removeListener('end', onend);
socket.removeListener('error', onerror);
socket.removeListener('close', onclose);
socket.removeListener('readable', read);
}
function onclose (err) {
debug('onclose had error %o', err);
}
function onend () {
debug('onend');
}
function onerror (err) {
cleanup();
fn(err);
}
function ondata (b) {
buffers.push(b);
buffersLength += b.length;
var buffered = Buffer.concat(buffers, buffersLength);
var str = buffered.toString('ascii');
if (!~str.indexOf('\r\n\r\n')) {
// keep buffering
debug('have not received end of HTTP headers yet...');
if (socket.read) {
read();
} else {
socket.once('data', ondata);
}
return;
}
var firstLine = str.substring(0, str.indexOf('\r\n'));
var statusCode = +firstLine.split(' ')[1];
debug('got proxy server response: %o', firstLine);
if (200 == statusCode) {
// 200 Connected status code!
var sock = socket;
// nullify the buffered data since we won't be needing it
buffers = buffered = null;
if (opts.secureEndpoint) {
// since the proxy is connecting to an SSL server, we have
// to upgrade this socket connection to an SSL connection
debug('upgrading proxy-connected socket to TLS connection: %o', opts.host);
opts.socket = socket;
opts.servername = opts.host;
opts.host = null;
opts.hostname = null;
opts.port = null;
sock = tls.connect(opts);
}
cleanup();
fn(null, sock);
} else {
// some other status code that's not 200... need to re-play the HTTP header
// "data" events onto the socket once the HTTP machinery is attached so that
// the user can parse and handle the error status code
cleanup();
// save a reference to the concat'd Buffer for the `onsocket` callback
buffers = buffered;
// need to wait for the "socket" event to re-play the "data" events
req.once('socket', onsocket);
fn(null, socket);
}
}
function onsocket (socket) {
// replay the "buffers" Buffer onto the `socket`, since at this point
// the HTTP module machinery has been hooked up for the user
if ('function' == typeof socket.ondata) {
// node <= v0.11.3, the `ondata` function is set on the socket
socket.ondata(buffers, 0, buffers.length);
} else if (socket.listeners('data').length > 0) {
// node > v0.11.3, the "data" event is listened for directly
socket.emit('data', buffers);
} else {
// never?
throw new Error('should not happen...');
}
// nullify the cached Buffer instance
buffers = null;
}
socket.on('error', onerror);
socket.on('close', onclose);
socket.on('end', onend);
if (socket.read) {
read();
} else {
socket.once('data', ondata);
}
var hostname = opts.host + ':' + opts.port;
var msg = 'CONNECT ' + hostname + ' HTTP/1.1\r\n';
var auth = proxy.auth;
if (auth) {
msg += 'Proxy-Authorization: Basic ' + new Buffer(auth).toString('base64') + '\r\n';
}
msg += 'Host: ' + hostname + '\r\n' +
'Connection: close\r\n' +
'\r\n';
socket.write(msg);
};

86
node_modules/https-proxy-agent/package.json generated vendored Normal file
View File

@ -0,0 +1,86 @@
{
"_args": [
[
"https-proxy-agent@^1.0.0",
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\popsicle-proxy-agent"
]
],
"_from": "https-proxy-agent@>=1.0.0-0 <2.0.0-0",
"_id": "https-proxy-agent@1.0.0",
"_inCache": true,
"_location": "/https-proxy-agent",
"_nodeVersion": "0.12.6",
"_npmUser": {
"email": "nathan@tootallnate.net",
"name": "tootallnate"
},
"_npmVersion": "2.11.2",
"_phantomChildren": {},
"_requested": {
"name": "https-proxy-agent",
"raw": "https-proxy-agent@^1.0.0",
"rawSpec": "^1.0.0",
"scope": null,
"spec": ">=1.0.0-0 <2.0.0-0",
"type": "range"
},
"_requiredBy": [
"/popsicle-proxy-agent"
],
"_resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
"_shasum": "35f7da6c48ce4ddbfa264891ac593ee5ff8671e6",
"_shrinkwrap": null,
"_spec": "https-proxy-agent@^1.0.0",
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\popsicle-proxy-agent",
"author": {
"email": "nathan@tootallnate.net",
"name": "Nathan Rajlich",
"url": "http://n8.io/"
},
"bugs": {
"url": "https://github.com/TooTallNate/node-https-proxy-agent/issues"
},
"dependencies": {
"agent-base": "2",
"debug": "2",
"extend": "3"
},
"description": "An HTTP(s) proxy `http.Agent` implementation for HTTPS",
"devDependencies": {
"mocha": "2",
"proxy": "~0.2.3",
"semver": "~2.2.1"
},
"directories": {},
"dist": {
"shasum": "35f7da6c48ce4ddbfa264891ac593ee5ff8671e6",
"tarball": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz"
},
"gitHead": "cb7577b6aa9a2466ca7612b1ebd6fc281407187f",
"homepage": "https://github.com/TooTallNate/node-https-proxy-agent#readme",
"installable": true,
"keywords": [
"agent",
"endpoint",
"https",
"proxy"
],
"license": "MIT",
"main": "https-proxy-agent.js",
"maintainers": [
{
"name": "tootallnate",
"email": "nathan@tootallnate.net"
}
],
"name": "https-proxy-agent",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/TooTallNate/node-https-proxy-agent.git"
},
"scripts": {
"test": "mocha --reporter spec"
},
"version": "1.0.0"
}

View File

@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQCzURxIqzer0ACAbX/lHdsn4Gd9PLKrf7EeDYfIdV0HZKPD8WDr
bBx2/fBu0OW2sjnzv/SVZbJ0DAuPE/p0+eT0qb2qC10iz9iTD7ribd7gxhirVb8y
b3fBjXsxc8V8p4Ny1LcvNSqCjwUbJqdRogfoJeTiqPM58z5sNzuv5iq7iwIDAQAB
AoGAPMQy4olrP0UotlzlJ36bowLP70ffgHCwU+/f4NWs5fF78c3du0oSx1w820Dd
Z7E0JF8bgnlJJTxjumPZz0RUCugrEHBKJmzEz3cxF5E3+7NvteZcjKn9D67RrM5x
1/uSZ9cqKE9cYvY4fSuHx18diyZ4axR/wB1Pea2utjjDM+ECQQDb9ZbmmaWMiRpQ
5Up+loxP7BZNPsEVsm+DVJmEFbaFgGfncWBqSIqnPNjMwTwj0OigTwCAEGPkfRVW
T0pbYWCxAkEA0LK7SCTwzyDmhASUalk0x+3uCAA6ryFdwJf/wd8TRAvVOmkTEldX
uJ7ldLvfrONYO3v56uKTU/SoNdZYzKtO+wJAX2KM4ctXYy5BXztPpr2acz4qHa1N
Bh+vBAC34fOYhyQ76r3b1btHhWZ5jbFuZwm9F2erC94Ps5IaoqcX07DSwQJAPKGw
h2U0EPkd/3zVIZCJJQya+vgWFIs9EZcXVtvYXQyTBkVApTN66MhBIYjzkub5205J
bVQmOV37AKklY1DhwQJAA1wos0cYxro02edzatxd0DIR2r4qqOqLkw6BhYHhq6HJ
ZvIcQkHqdSXzdETFc01I1znDGGIrJHcnvKWgBPoEUg==
-----END RSA PRIVATE KEY-----

View File

@ -0,0 +1,12 @@
-----BEGIN CERTIFICATE-----
MIIB1TCCAT4CCQDV5mPlzm9+izANBgkqhkiG9w0BAQUFADAvMS0wKwYDVQQDEyQ3
NTI3YmQ3Ny1hYjNlLTQ3NGItYWNlNy1lZWQ2MDUzOTMxZTcwHhcNMTUwNzA2MjI0
NTA3WhcNMjUwNzAzMjI0NTA3WjAvMS0wKwYDVQQDEyQ3NTI3YmQ3Ny1hYjNlLTQ3
NGItYWNlNy1lZWQ2MDUzOTMxZTcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
ALNRHEirN6vQAIBtf+Ud2yfgZ308sqt/sR4Nh8h1XQdko8PxYOtsHHb98G7Q5bay
OfO/9JVlsnQMC48T+nT55PSpvaoLXSLP2JMPuuJt3uDGGKtVvzJvd8GNezFzxXyn
g3LUty81KoKPBRsmp1GiB+gl5OKo8znzPmw3O6/mKruLAgMBAAEwDQYJKoZIhvcN
AQEFBQADgYEACzoHUF8UV2Z6541Q2wKEA0UFUzmUjf/E1XwBO+1P15ZZ64uw34B4
1RwMPtAo9RY/PmICTWtNxWGxkzwb2JtDWtnxVER/lF8k2XcXPE76fxTHJF/BKk9J
QU8OTD1dd9gHCBviQB9TqntRZ5X7axjtuWjb2umY+owBYzAHZkp1HKI=
-----END CERTIFICATE-----

293
node_modules/https-proxy-agent/test/test.js generated vendored Normal file
View File

@ -0,0 +1,293 @@
/**
* Module dependencies.
*/
var fs = require('fs');
var url = require('url');
var http = require('http');
var https = require('https');
var assert = require('assert');
var Proxy = require('proxy');
var Semver = require('semver');
var version = new Semver(process.version);
var HttpsProxyAgent = require('../');
describe('HttpsProxyAgent', function () {
var server;
var serverPort;
var sslServer;
var sslServerPort;
var proxy;
var proxyPort;
var sslProxy;
var sslProxyPort;
before(function (done) {
// setup target HTTP server
server = http.createServer();
server.listen(function () {
serverPort = server.address().port;
done();
});
});
before(function (done) {
// setup HTTP proxy server
proxy = Proxy();
proxy.listen(function () {
proxyPort = proxy.address().port;
done();
});
});
before(function (done) {
// setup target HTTPS server
var options = {
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
};
sslServer = https.createServer(options);
sslServer.listen(function () {
sslServerPort = sslServer.address().port;
done();
});
});
before(function (done) {
// setup SSL HTTP proxy server
var options = {
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
};
sslProxy = Proxy(https.createServer(options));
sslProxy.listen(function () {
sslProxyPort = sslProxy.address().port;
done();
});
});
// shut down test HTTP server
after(function (done) {
server.once('close', function () { done(); });
server.close();
});
after(function (done) {
proxy.once('close', function () { done(); });
proxy.close();
});
after(function (done) {
sslServer.once('close', function () { done(); });
sslServer.close();
});
after(function (done) {
sslProxy.once('close', function () { done(); });
sslProxy.close();
});
describe('constructor', function () {
it('should throw an Error if no "proxy" argument is given', function () {
assert.throws(function () {
new HttpsProxyAgent();
});
});
it('should accept a "string" proxy argument', function () {
var agent = new HttpsProxyAgent('http://127.0.0.1:' + proxyPort);
assert.equal('127.0.0.1', agent.proxy.host);
assert.equal(proxyPort, agent.proxy.port);
});
it('should accept a `url.parse()` result object argument', function () {
var opts = url.parse('http://127.0.0.1:' + proxyPort);
var agent = new HttpsProxyAgent(opts);
assert.equal('127.0.0.1', agent.proxy.host);
assert.equal(proxyPort, agent.proxy.port);
});
describe('secureProxy', function () {
it('should default to `false`', function () {
var agent = new HttpsProxyAgent({ port: proxyPort });
assert.equal(false, agent.secureProxy);
});
it('should be `false` when "http:" protocol is used', function () {
var agent = new HttpsProxyAgent({ port: proxyPort, protocol: 'http:' });
assert.equal(false, agent.secureProxy);
});
it('should be `true` when "https:" protocol is used', function () {
var agent = new HttpsProxyAgent({ port: proxyPort, protocol: 'https:' });
assert.equal(true, agent.secureProxy);
});
it('should be `true` when "https" protocol is used', function () {
var agent = new HttpsProxyAgent({ port: proxyPort, protocol: 'https' });
assert.equal(true, agent.secureProxy);
});
});
});
describe('"http" module', function () {
beforeEach(function () {
delete proxy.authenticate;
});
it('should work over an HTTP proxy', function (done) {
server.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var proxy = process.env.HTTP_PROXY || process.env.http_proxy || 'http://127.0.0.1:' + proxyPort;
var agent = new HttpsProxyAgent(proxy);
var opts = url.parse('http://127.0.0.1:' + serverPort);
opts.agent = agent;
var req = http.get(opts, function (res) {
var data = '';
res.setEncoding('utf8');
res.on('data', function (b) {
data += b;
});
res.on('end', function () {
data = JSON.parse(data);
assert.equal('127.0.0.1:' + serverPort, data.host);
done();
});
});
req.once('error', done);
});
it('should work over an HTTPS proxy', function (done) {
server.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort;
proxy = url.parse(proxy);
proxy.rejectUnauthorized = false;
var agent = new HttpsProxyAgent(proxy);
var opts = url.parse('http://127.0.0.1:' + serverPort);
opts.agent = agent;
http.get(opts, function (res) {
var data = '';
res.setEncoding('utf8');
res.on('data', function (b) {
data += b;
});
res.on('end', function () {
data = JSON.parse(data);
console.log(data);
assert.equal('127.0.0.1:' + serverPort, data.host);
done();
});
});
});
it('should receive the 407 authorization code on the `http.ClientResponse`', function (done) {
// set a proxy authentication function for this test
proxy.authenticate = function (req, fn) {
// reject all requests
fn(null, false);
};
var proxyUri = process.env.HTTP_PROXY || process.env.http_proxy || 'http://127.0.0.1:' + proxyPort;
var agent = new HttpsProxyAgent(proxyUri);
var opts = {};
// `host` and `port` don't really matter since the proxy will reject anyways
opts.host = '127.0.0.1';
opts.port = 80;
opts.agent = agent;
var req = http.get(opts, function (res) {
assert.equal(407, res.statusCode);
assert('proxy-authenticate' in res.headers);
done();
});
});
it('should emit an "error" event on the `http.ClientRequest` if the proxy does not exist', function (done) {
// port 4 is a reserved, but "unassigned" port
var proxyUri = 'http://127.0.0.1:4';
var agent = new HttpsProxyAgent(proxyUri);
var opts = url.parse('http://nodejs.org');
opts.agent = agent;
var req = http.get(opts);
req.once('error', function (err) {
assert.equal('ECONNREFUSED', err.code);
req.abort();
done();
});
});
});
describe('"https" module', function () {
it('should work over an HTTP proxy', function (done) {
sslServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var proxy = process.env.HTTP_PROXY || process.env.http_proxy || 'http://127.0.0.1:' + proxyPort;
var agent = new HttpsProxyAgent(proxy);
var opts = url.parse('https://127.0.0.1:' + sslServerPort);
opts.rejectUnauthorized = false;
opts.agent = agent;
https.get(opts, function (res) {
var data = '';
res.setEncoding('utf8');
res.on('data', function (b) {
data += b;
});
res.on('end', function () {
data = JSON.parse(data);
assert.equal('127.0.0.1:' + sslServerPort, data.host);
done();
});
});
});
if (version.compare('0.11.3') < 0 || version.compare('0.11.8') >= 0) {
// This test is disabled on node >= 0.11.3 && < 0.11.8, since it segfaults :(
// See: https://github.com/joyent/node/issues/6204
it('should work over an HTTPS proxy', function (done) {
sslServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var proxy = process.env.HTTPS_PROXY || process.env.https_proxy || 'https://127.0.0.1:' + sslProxyPort;
proxy = url.parse(proxy);
proxy.rejectUnauthorized = false;
var agent = new HttpsProxyAgent(proxy);
var opts = url.parse('https://127.0.0.1:' + sslServerPort);
opts.agent = agent;
opts.rejectUnauthorized = false;
https.get(opts, function (res) {
var data = '';
res.setEncoding('utf8');
res.on('data', function (b) {
data += b;
});
res.on('end', function () {
data = JSON.parse(data);
assert.equal('127.0.0.1:' + sslServerPort, data.host);
done();
});
});
});
} else {
it('should work over an HTTPS proxy');
}
});
});