From d0c82633974f762c20e7ff3140d786b025eeacec Mon Sep 17 00:00:00 2001 From: irony Date: Wed, 28 Mar 2012 13:10:54 +0200 Subject: [PATCH 1/2] Added option for setting followAllRedirects to allow redirects on POST requests --- .project | 12 ++++++++++++ lib/node.io/request.js | 1 + 2 files changed, 13 insertions(+) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000..c61910f --- /dev/null +++ b/.project @@ -0,0 +1,12 @@ + + + node-io-iteam + + + + + + + com.aptana.projects.webnature + + diff --git a/lib/node.io/request.js b/lib/node.io/request.js index 7924934..3a4b2b4 100755 --- a/lib/node.io/request.js +++ b/lib/node.io/request.js @@ -272,6 +272,7 @@ Job.prototype.doRequest = function (method, resource, body, headers, callback, p headers: headers, body: body, maxRedirects: this.options.redirects, + followAllRedirects:this.options.followAllRedirects, encoding: this.options.encoding, pool: false } From d2490425a5ba53af84a59e9f0feb660ed48564f4 Mon Sep 17 00:00:00 2001 From: irony Date: Wed, 28 Mar 2012 13:14:58 +0200 Subject: [PATCH 2/2] Added test for post redirect --- test/request.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/request.test.js b/test/request.test.js index d1cea86..cacb890 100755 --- a/test/request.test.js +++ b/test/request.test.js @@ -342,6 +342,30 @@ module.exports = { }, timeout); }, + + 'test POST request with too many redirects': function() { + + var job = createJob({followAllRedirects : true}); + + var server = http.createServer(function (req, res) { + res.writeHead(302, {'Content-Type': 'text/plain', 'Location': '/'}); + res.end(); + }); + + server.listen(++port); + + job.post('http://127.0.0.1:'+port+'/', {foo:'bar'}, function(err, data, headers) { + assert.equal('redirects', err); + assert.equal(null, data); + close(server); + }); + + setTimeout(function() { + close(server); + }, timeout); + }, + + 'test get() is in same scope as job': function() { var job = createJob();