Skip to content
Browse files

A test of POST redirect following with 303 status

Re: #289
  • Loading branch information...
1 parent d38e57b commit 820af5839f2a193d091d98f23fd588bd919e3e58 @isaacs committed Jul 30, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 tests/test-follow-all-303.js
View
30 tests/test-follow-all-303.js
@@ -0,0 +1,30 @@
+var request = require('request');
+var http = require('http');
+var requests = 0;
+var assert = require('assert');
+
+var server = http.createServer(function (req, res) {
+ console.error(req.method, req.url);
+ requests ++;
+
+ if (req.method === 'POST') {
+ console.error('send 303');
+ res.setHeader('location', req.url);
+ res.statusCode = 303;
+ res.end('try again, i guess\n');
+ } else {
+ console.error('send 200')
+ res.end('ok: ' + requests);
+ }
+});
+server.listen(6767);
+
+request.post({ url: 'http://localhost:6767/foo',
+ followAllRedirects: true,
+ form: { foo: 'bar' } }, function (er, req, body) {
+ if (er) throw er;
+ assert.equal(body, 'ok: 2');
+ assert.equal(requests, 2);
+ console.error('ok - ' + process.version);
+ server.close();
+});

0 comments on commit 820af58

Please sign in to comment.
Something went wrong with that request. Please try again.