Skip to content

Commit df7f7be

Browse files
authored
Allow passing in agent
I needed this so that I could use https://github.com/TooTallNate/node-socks-proxy-agent to configure a Socks proxy to access our WPT instance.
1 parent 4305331 commit df7f7be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/webpagetest.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var filenames = {
5656
};
5757

5858
// GET helper function
59-
function get(config, pathname, proxy, callback, encoding) {
59+
function get(config, pathname, proxy, agent, callback, encoding) {
6060
var protocol,
6161
options;
6262

@@ -93,6 +93,10 @@ function get(config, pathname, proxy, callback, encoding) {
9393
if (encoding !== 'binary') {
9494
options.headers['accept-encoding'] = 'gzip,deflate';
9595
}
96+
97+
if (agent) {
98+
options.agent = agent;
99+
}
96100

97101
return protocol.get(options, function getResponse(res) {
98102
var data, length,
@@ -191,7 +195,7 @@ function api(pathname, callback, query, options) {
191195
} else {
192196

193197
// make the real API call
194-
get.call(this, config, pathname, options.proxy, function apiCallback(err, data, info) {
198+
get.call(this, config, pathname, options.proxy, options.agent, function apiCallback(err, data, info) {
195199
if (!err) {
196200
try {
197201
if (options.parser) {

0 commit comments

Comments
 (0)