Skip to content
This repository

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 almost 2 years ago

2 participants

irony Chris O'Hara
irony
irony commented

No description provided.

Chris O'Hara
Owner
chriso commented

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

Chris O'Hara chriso merged commit 4968447 into from
Chris O'Hara chriso closed this
irony
irony commented

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

Chris O'Hara
Owner
chriso commented

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.
12  .project
... ...
@@ -0,0 +1,12 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<projectDescription>
  3
+	<name>node-io-iteam</name>
  4
+	<comment></comment>
  5
+	<projects>
  6
+	</projects>
  7
+	<buildSpec>
  8
+	</buildSpec>
  9
+	<natures>
  10
+		<nature>com.aptana.projects.webnature</nature>
  11
+	</natures>
  12
+</projectDescription>
1  lib/node.io/request.js
@@ -272,6 +272,7 @@ Job.prototype.doRequest = function (method, resource, body, headers, callback, p
272 272
         headers: headers,
273 273
         body: body,
274 274
         maxRedirects: this.options.redirects,
  275
+        followAllRedirects:this.options.followAllRedirects,
275 276
         encoding: this.options.encoding,
276 277
         pool: false
277 278
     }
24  test/request.test.js
@@ -342,6 +342,30 @@ module.exports = {
342 342
         }, timeout);
343 343
     },
344 344
 
  345
+
  346
+    'test POST request with too many redirects': function() {
  347
+
  348
+        var job = createJob({followAllRedirects : true});
  349
+
  350
+        var server = http.createServer(function (req, res) {
  351
+            res.writeHead(302, {'Content-Type': 'text/plain', 'Location': '/'});
  352
+            res.end();
  353
+        });
  354
+
  355
+        server.listen(++port);
  356
+
  357
+        job.post('http://127.0.0.1:'+port+'/', {foo:'bar'}, function(err, data, headers) {
  358
+            assert.equal('redirects', err);
  359
+            assert.equal(null, data);
  360
+            close(server);
  361
+        });
  362
+
  363
+        setTimeout(function() {
  364
+            close(server);
  365
+        }, timeout);
  366
+    },
  367
+
  368
+
345 369
     'test get() is in same scope as job': function() {
346 370
 
347 371
         var job = createJob();
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.