Skip to content
Open
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
10 changes: 8 additions & 2 deletions lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ var Url = require("url")
, spawn = require("child_process").spawn
, fs = require('fs');

exports.XMLHttpRequest = function() {
/**
*
* @param http.Agent agent An http.Agent instance; http.globalAgent may be used; if 'undefined', agent usage is disabled; (optional)
*/
exports.XMLHttpRequest = function(agent) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future-proof-ness, maybe we should make this be an "options" object with and agent property. That allows for more options to be added in the future without adding unnecessary arguments.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. I'm about to send in an optional proxy as well.

/**
* Private variables
*/
Expand Down Expand Up @@ -97,6 +101,8 @@ exports.XMLHttpRequest = function() {
* Public vars
*/

this.agent = agent || false;

// Current state
this.readyState = this.UNSENT;

Expand Down Expand Up @@ -359,7 +365,7 @@ exports.XMLHttpRequest = function() {
path: uri,
method: settings.method,
headers: headers,
agent: false
agent: this.agent
};

// Reset error flag
Expand Down