Sha256: 50de248e5c5bf0fbd7750844e6e3cb8a19701f3c50944fb32367ceffd178527b

Contents?: true

Size: 850 Bytes

Versions: 19

Compression:

Stored size: 850 Bytes

Contents

var request = require('../index');
var http = require('http');
var requests = 0;
var assert = require('assert');

var server = http.createServer(function (req, res) {
  requests ++;

  // redirect everything 3 times, no matter what.
  var c = req.headers.cookie;

  if (!c) c = 0;
  else c = +c.split('=')[1] || 0;

  if (c > 3) {
    res.end('ok: '+requests);
    return;
  }

  res.setHeader('set-cookie', 'c=' + (c + 1));
  res.setHeader('location', req.url);
  res.statusCode = 302;
  res.end('try again, i guess\n');
});
server.listen(6767);

request.post({ url: 'http://localhost:6767/foo',
               followAllRedirects: true,
               form: { foo: 'bar' } }, function (er, req, body) {
  if (er) throw er;
  assert.equal(body, 'ok: 5');
  assert.equal(requests, 5);
  console.error('ok - ' + process.version);
  server.close();
});

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 node_modules/request/tests/test-follow-all.js
ela-4.1.5 node_modules/request/tests/test-follow-all.js
ela-4.1.4 node_modules/request/tests/test-follow-all.js
ela-4.1.3 node_modules/request/tests/test-follow-all.js
ela-4.1.2 node_modules/request/tests/test-follow-all.js
ela-4.1.1 node_modules/request/tests/test-follow-all.js
ela-4.1.0 node_modules/request/tests/test-follow-all.js
ela-4.0.0 node_modules/request/tests/test-follow-all.js
ela-3.4.3 node_modules/request/tests/test-follow-all.js
ela-3.4.2 node_modules/request/tests/test-follow-all.js
ela-3.4.0 node_modules/request/tests/test-follow-all.js
ela-3.3.1 node_modules/request/tests/test-follow-all.js
ela-3.3.0 node_modules/request/tests/test-follow-all.js
ela-3.2.0 node_modules/request/tests/test-follow-all.js
ela-3.1.1 node_modules/request/tests/test-follow-all.js
ela-3.1.0 node_modules/request/tests/test-follow-all.js
ela-3.0.0 node_modules/request/tests/test-follow-all.js
ela-2.0.0 node_modules/request/tests/test-follow-all.js
ela-1.1.0 node_modules/request/tests/test-follow-all.js