Skip to content

Commit

Permalink
ApiRequest: Clone the request options before modifying them
Browse files Browse the repository at this point in the history
With the introduction of mwApiServer, ApiRequest.request started
modifying the request options object before issuing a request to the MW
API. However, the object itself is a property of its sub-classes, which
means that ApiRequest.request was modifying permanently the URI. Hence,
clone the request options object before modifying it.

Bug: T153797
Change-Id: Ibf4cf2fdab74d742c66aedc82379a57def91440a
  • Loading branch information
Marko Obrovac committed Dec 21, 2016
1 parent 5eb649e commit e7e3a4d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/mw/ApiRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ util.inherits(ApiRequest, events.EventEmitter);
var httpAgent = null;
var httpsAgent = null;

ApiRequest.prototype.request = function(options, callback) {
ApiRequest.prototype.request = function(requestOpts, callback) {
var env = this.env;
var proxy = this.proxy;
var mwApiServer = this.mwApiServer;
var options = Object.assign({}, requestOpts);

// this is a good place to put debugging statements
// if you want to watch network requests.
Expand Down

0 comments on commit e7e3a4d

Please sign in to comment.