Skip to content
Open
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: 4 additions & 2 deletions src/gatherers/webpagetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class WebPageTestGatherer extends Gatherer {
urlParams.push(key + '=' + params[key]);
});
let url = this.runApiEndpoint + '?' + urlParams.join('&');
options.headers = options.headers || {};
options.headers['X-WPT-API-KEY'] = this.apiKey;

let response, body = {}, statusText;
if (this.apiKey === 'TEST_APIKEY') {
Expand All @@ -193,7 +195,7 @@ class WebPageTestGatherer extends Gatherer {

} else {
if (this.debug) console.log('WPTGatherer::run\n', url);
response = this.apiHandler.fetch(url);
response = this.apiHandler.fetch(url, options);

if (this.debug) {
console.log('WPTGatherer::run API response: \n', response);
Expand Down Expand Up @@ -298,7 +300,7 @@ class WebPageTestGatherer extends Gatherer {
let url = this.resultApiEndpoint + '?' + urlParams.join('&');
if (this.debug) console.log('WPTGatherer::retrieve\n', url);

let response = this.apiHandler.fetch(url);
let response = this.apiHandler.fetch(url, options);

if (response.statusCode >= 400) {
return {
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/appscript-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
const ApiHandler = require('./api-handler');

class AppScriptApiHandler extends ApiHandler {
fetch(url) {
return this.get(url);
fetch(url, options) {
return this.get(url, options);
}

get(url) {
get(url, options) {
try {
var response = UrlFetchApp.fetch(url);
var response = UrlFetchApp.fetch(url, options);
return {
statusCode: response.getResponseCode(),
body: response.getContentText(),
Expand Down