These commits allow for configuration to also follow redirects (302) when issuing POST requests. The default is still not to follow them (why?) so it should be safe. I also added a test case which tests the functionality. Thanks of a great library! Keep u #98

Merged
merged 2 commits into from May 17, 2012
View
12 .project
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>node-io-iteam</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ <nature>com.aptana.projects.webnature</nature>
+ </natures>
+</projectDescription>
View
1 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
}
View
24 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();