Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var cli = meow({
'Options:',
' --device Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size).',
' --screenshot Will take a screenshot and use this value as the output path. It needs to end with ".png".',
' --wait-for-selector Once the page is loaded, Phantomas will wait until the given CSS selector matches some elements.',
//' --wait-for-selector Once the page is loaded, Phantomas will wait until the given CSS selector matches some elements.',
' --proxy Sets an HTTP proxy to pass through. Syntax is "host:port".',
' --cookie Adds a cookie on the main domain.',
' --auth-user Basic HTTP authentication username.',
' --auth-pass Basic HTTP authentication password.',
Expand Down Expand Up @@ -56,6 +57,9 @@ options.device = cli.flags.device || 'desktop';
// Wait for CSS selector
options.waitForSelector = cli.flags.waitForSelector || null;

// Proxy
options.proxy = cli.flags.proxy || null;

// Cookie
options.cookie = cli.flags.cookie || null;

Expand Down
1 change: 1 addition & 0 deletions front/src/js/services/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apiService.factory('API', ['$location', 'Runs', 'Results', function($location, R
screenshot: true,
device: settings.device,
waitForSelector: settings.waitForSelector,
proxy: settings.proxy,
cookie: settings.cookie,
authUser: settings.authUser,
authPass: settings.authPass,
Expand Down
10 changes: 10 additions & 0 deletions front/src/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ <h2 class="promess">Online test to help speeding up <b>heavy</b> web pages</h2>
</div>
</div>
</div>
<div>
<div class="label">
HTTP proxy
<span class="settingsTooltip">
<span class="icon-question"></span>
<div><b>HTTP proxy</b><br><br>Insert here your proxy settings with the format "host:port".<br><br>Example: "192.168.10.0:3333"</div>
</span>
</div>
<div><input type="text" name="proxy" ng-model="settings.proxy" /></div>
</div>
<div>
<div class="label">
Block domains
Expand Down
2 changes: 2 additions & 0 deletions lib/server/controllers/apiController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions lib/tools/phantomas/phantomasWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
15 changes: 12 additions & 3 deletions lib/tools/redownload/redownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)

Expand Down Expand Up @@ -558,7 +566,7 @@ var Redownload = function() {
}


function redownloadEntry(entry, httpAuth) {
function redownloadEntry(entry, httpAuth, proxy) {
var deferred = Q.defer();

function downloadError(message) {
Expand Down Expand Up @@ -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
Expand Down