From 05d90e60680d81516f3a49209d17f3556b687770 Mon Sep 17 00:00:00 2001 From: vflyson Date: Mon, 20 Feb 2017 04:06:48 -0500 Subject: [PATCH] Add user-agent to the request headers to be less shady --- functions.js | 8 +++++++- options.js | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/functions.js b/functions.js index 9141870..292817f 100644 --- a/functions.js +++ b/functions.js @@ -7,6 +7,12 @@ var options = require('./options.js'); var cache = {} +var request_options = { + 'headers': { + 'user-agent': options.userAgentString + } +} + // Note: http://site.com/image/icons/home.png -> http://site.com/image/icons function absoluteURLPath (aURL) { var URL = url.parse(aURL) @@ -49,7 +55,7 @@ function retrieveFile (aAbsBasePath, aFilePath, aBinary) { return cache[cacheKey] } else { try { - var res = request('GET', fullFilePath) + var res = request('GET', fullFilePath, request_options) if (!options.suppressVerboseOutput) console.warn('Retrieving file', fullFilePath, '...') diff --git a/options.js b/options.js index a10c9da..22ec299 100644 --- a/options.js +++ b/options.js @@ -1,6 +1,9 @@ +'use strict' + var options = { outputFinalResultAsBase64: false, - suppressVerboseOutput: false + suppressVerboseOutput: false, + userAgentString: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36', } module.exports = options