Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

2 participants

@irony

No description provided.

@chriso
Owner

Thanks. The request library node.io uses changes its API often. When I incorporated it originally this was the default behaviour :/

@chriso chriso merged commit 4968447 into chriso:master
@irony

I understand, no problem. Do you want me to ask @Mikeal to merge this fix as well?

@chriso
Owner

No, it's not an issue on that end, just a matter of locking in a version of request and watching out for changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 37 additions and 0 deletions.
  1. +12 −0 .project
  2. +1 −0  lib/node.io/request.js
  3. +24 −0 test/request.test.js
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();
Something went wrong with that request. Please try again.