Add proxy to the setting (#213)

This commit is contained in:
Gaël Métais
2016-12-20 22:37:20 +08:00
committed by GitHub
parent 5d081f27d1
commit 317b0fc4d7
6 changed files with 36 additions and 4 deletions
+2
View File
@@ -32,6 +32,7 @@ var ApiController = function(app) {
partialResult: req.body.partialResult || null,
screenshot: req.body.screenshot || false,
device: req.body.device || 'desktop',
proxy: req.body.proxy || null,
waitForSelector: req.body.waitForSelector || null,
cookie: req.body.cookie || null,
authUser: req.body.authUser || null,
@@ -71,6 +72,7 @@ var ApiController = function(app) {
var runOptions = {
screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false,
device: run.params.device,
proxy: run.params.proxy,
waitForSelector: run.params.waitForSelector,
cookie: run.params.cookie,
authUser: run.params.authUser,
+6
View File
@@ -59,6 +59,12 @@ var PhantomasWrapper = function() {
].join(',')
};
// Proxy option can't be set to null or undefined...
// this is why it's set now and not in the object above
if (task.options.proxy) {
options.proxy = task.options.proxy;
}
// Output the command line for debugging purpose
debug('If you want to reproduce the phantomas task only, copy the following command line:');
var optionsString = '';
+12 -3
View File
@@ -45,6 +45,14 @@ var Redownload = function() {
};
}
var proxy = null;
if (data.params && data.params.options && data.params.options.proxy) {
proxy = data.params.options.proxy;
if (proxy.indexOf('http:') === -1) {
proxy = 'http://' + proxy;
}
}
// Prevent a bug with the font analyzer on empty pages
var differentCharacters = '';
if (data.toolsResults.phantomas.offenders.differentCharacters && data.toolsResults.phantomas.offenders.differentCharacters.length > 0) {
@@ -55,7 +63,7 @@ var Redownload = function() {
var redownloadList = requestsList.map(function(entry) {
return function(callback) {
redownloadEntry(entry, httpAuth)
redownloadEntry(entry, httpAuth, proxy)
.then(contentTypeChecker.checkContentType)
@@ -558,7 +566,7 @@ var Redownload = function() {
}
function redownloadEntry(entry, httpAuth) {
function redownloadEntry(entry, httpAuth, proxy) {
var deferred = Q.defer();
function downloadError(message) {
@@ -610,7 +618,8 @@ var Redownload = function() {
method: entry.method,
url: entry.url,
headers: reqHeaders,
timeout: REQUEST_TIMEOUT
timeout: REQUEST_TIMEOUT,
proxy: proxy
};
// Basic auth