Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Now you activate user agent spoofing while still be able to use setUs…
…erAgent("my agent just for a request")
  • Loading branch information
laurentdebricon committed Jun 12, 2012
1 parent 650942a commit 8aa8003
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/node.io/request.js
Expand Up @@ -234,6 +234,11 @@ Job.prototype.doRequest = function (method, resource, body, headers, callback, p

//Copy `headers` before modifying it
headers = utils.put({}, headers);

//Set a random user agent if using --spoof
if (this.options.spoof) {
headers['user-agent'] = user_agents[Math.floor(Math.random() * user_agents.length)];
}

//Add headers from a previous request if this is a nested request
if (this.last.headers) {
Expand All @@ -244,11 +249,6 @@ Job.prototype.doRequest = function (method, resource, body, headers, callback, p
utils.put(headers, this.next);
this.next = {};

//Set a random user agent if using --spoof
if (this.options.spoof) {
headers['user-agent'] = user_agents[Math.floor(Math.random() * user_agents.length)];
}

//Prepare the body to write and get the content length
if (body) {
if (typeof body === 'object') {
Expand Down

0 comments on commit 8aa8003

Please sign in to comment.