title: protractor throwing 'TypeError: Cannot read property 'statusCode' of undefined' on request callback
body: <p>I'm writing UI tests with protractor and I'm uploading files directly through a RESTful service instead of using UI. I have the following method</p>
  
  <pre><code>var defer = protractor.promise.defer();
  request(options, function (error, response, body) {
      if (!error &amp;&amp; response.statusCode == 201) {
          var info = JSON.parse(body);
          defer.fulfill(info);
      } else {
          defer.reject({
              error: error,
              message: response.statusCode
          });
      }
  });
  return defer.promise;
  </code></pre>
  
  <p>Note: API returns 201 if uploaded successfully.</p>
  
  <p>Works fine when I run the code through my IDE (in Windows), but I want to run the tests through Jenkins (over Ubuntu) and in that case I get the error:</p>
  
  <pre><code>E/launcher - TypeError: Cannot read property 'statusCode' of undefined
      at Request._callback (file.js:144:34)
      at self.callback (/workspace/node_modules/request/request.js:186:22)
      at emitOne (events.js:101:20)
      at Request.emit (events.js:188:7)
      at Request.onRequestError (/workspace/node_modules/request/request.js:845:8)
      at emitOne (events.js:96:13)
      at ClientRequest.emit (events.js:188:7)
      at Socket.socketErrorListener (_http_client.js:310:9)
      at emitOne (events.js:96:13)
      at Socket.emit (events.js:188:7)
  E/launcher - Process exited with error code 199
  </code></pre>
  
  <p>I'm not sure if this is related to some kind of configuration or if SO may be causing this, but I sure need guidance.</p>