Navigation Menu

Skip to content

Commit

Permalink
Merge pull request node-js-libs#98 from Iteam1337/master
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chriso committed May 17, 2012
2 parents 282d2ce + d249042 commit 4968447
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .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>
1 change: 1 addition & 0 deletions lib/node.io/request.js
Expand Up @@ -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
}
Expand Down
24 changes: 24 additions & 0 deletions test/request.test.js
Expand Up @@ -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();
Expand Down

0 comments on commit 4968447

Please sign in to comment.