Permalink
Browse files

Merge pull request #108 from laurentdebricon/patch-1

Activate user agent spoofing while still be able to use setUserAgent("my agent just for a request")
  • Loading branch information...
2 parents 650942a + 8aa8003 commit da0039db0c0984e6350a14b3677f5fa624c2b73e @chriso chriso committed Jun 19, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/node.io/request.js
View
@@ -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) {
@@ -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') {

0 comments on commit da0039d

Please sign in to comment.