code: function(options, callback, opt_data) {
    var request = http.request(options, function(response) {
      if (response.statusCode == 302 || response.statusCode == 303) {
        try {
          var location = url.parse(response.headers['location']);
        } catch (ex) {
          callback(Error(
              'Failed to parse "Location" header for server redirect: ' +
              ex.message + '\nResponse was: \n' +
              new HttpResponse(response.statusCode, response.headers, '')));
          return;
        }
  
        if (!location.hostname) {
          location.hostname = options.host;
          location.port = options.port;
        }
  
        request.abort();
        sendRequest({
          method: 'GET',
          host: location.hostname,
          path: location.pathname + (location.search || ''),
          port: location.port,
          headers: {
            'Accept': 'application/json; charset=utf-8'
          }
        }, callback);
        return;
      }
  
      var body = [];
      response.on('data', body.push.bind(body));
      response.on('end', function() {
        var resp = new HttpResponse(response.statusCode,
            response.headers, body.join('').replace(/\0/g, ''));
        callback(null, resp);
      });
    });
  
    request.on('error', function(e) {
      if (e.code === 'ECONNRESET') {
        setTimeout(function() {
          sendRequest(options, callback, opt_data);
        }, 15);
      } else {
        var message = e.message;
        if (e.code) {
          message = e.code + ' ' + message;
        }
        callback(new Error(message));
      }
    });
  
    if (opt_data) {
      request.write(opt_data);
    }
  
    request.end();
  }
docs: Sends a single HTTP request.
  @param {!Object} options The request options.
  @param {function(Error, !webdriver.http.Response=)} callback The function to
  invoke with the server's response.
  @param {string=} opt_data The data to send with the request.