Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.listen(0, function() {
var tunnel = require('tunnel-agent');
var agentSettings = {
proxy: {
host: server.address().host,
port: server.address().port
}
};
var proxyClient = algoliasearch(appId, apiKey, {
httpAgent: tunnel.httpsOverHttp(agentSettings)
});
var proxyIndex = proxyClient.initIndex(indexName);
proxyIndex
.browse()
.then(end)
.then(null, _.bind(t.error, t));
function end(content) {
server.close();
proxyClient.destroy();
t.ok(content.hits.length, 'We got some content');
}
});
}
export function assign (reqOpts: RequestOptions): void {
const proxy = reqOpts.proxy;
if (proxy && reqOpts.protocol === 'https:') {
reqOpts.agent = tunnel.httpsOverHttp({
proxy,
rejectUnauthorized: false
});
return;
}
let type = '';
if (reqOpts.protocol === 'http:')
type = TYPE.HTTP;
else if (ssl3HostCache.get(reqOpts.host))
type = TYPE.SSL3;
else
}
var options = assign({
proxy: {
host: this._proxyUri.hostname,
port: this._proxyUri.port || this.DEFAULT_PORTS[this._proxyUri.protocol],
proxyAuth: this._proxyUri.auth,
headers: assign({ host: this.endpoint.host }, proxy.headers)
}
}, this._dispatcher.tls);
if (this._proxySecure) {
assign(options.proxy, proxy.tls);
this._tunnel = tunnel.httpsOverHttps(options);
} else {
this._tunnel = tunnel.httpsOverHttp(options);
}
},
return new Promise(function (fulfill, reject) {
let httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
let agent;
if (httpsProxy) {
cli.hush(`proxy set to ${httpsProxy}`);
let proxy = url.parse(httpsProxy);
agent = tunnel.httpsOverHttp({
proxy: {
host: proxy.hostname,
port: proxy.port || 8080
}
});
} else {
agent = new https.Agent();
}
let requestOptions = url.parse(urlStr);
requestOptions.agent = agent;
let req = https.request(requestOptions, function (res) {
if (res.statusCode > 200 || res.statusCode >= 300) return reject(new Error(res.body));
res.pipe(fs.createWriteStream(tmpPath, opts));
res.on('end', fulfill);
util.getTunnelAgent = (requestIsSSL, externalProxyUrl) => {
var urlObject = url.parse(externalProxyUrl);
var protocol = urlObject.protocol || 'http:';
var port = urlObject.port;
if (!port) {
port = protocol === 'http:' ? 80 : 443;
}
var hostname = urlObject.hostname || 'localhost';
if (requestIsSSL) {
if (protocol === 'http:') {
if (!httpsOverHttpAgent) {
httpsOverHttpAgent = tunnelAgent.httpsOverHttp({
proxy: {
host: hostname,
port: port
}
});
}
return httpsOverHttpAgent
} else {
if (!httpsOverHttpsAgent) {
httpsOverHttpsAgent = tunnelAgent.httpsOverHttps({
proxy: {
host: hostname,
port: port
}
});
}
var config = require('../config');
var httpAgent;
var httpsAgent;
if (config.httpProxy) {
var tunnel = require('tunnel-agent');
var urlinfo = urlparse(config.httpProxy);
if (urlinfo.protocol === 'http:') {
httpAgent = tunnel.httpOverHttp({
proxy: {
host: urlinfo.hostname,
port: urlinfo.port
}
});
httpsAgent = tunnel.httpsOverHttp({
proxy: {
host: urlinfo.hostname,
port: urlinfo.port
}
});
} else if (urlinfo.protocol === 'https:') {
httpAgent = tunnel.httpOverHttps({
proxy: {
host: urlinfo.hostname,
port: urlinfo.port
}
});
httpsAgent = tunnel.httpsOverHttps({
proxy: {
host: urlinfo.hostname,
port: urlinfo.port