Sha256: 7e8204dead5c7b5d14852faa61fff4dd60429e956e270cbd455fcd72e0660d40

Contents?: true

Size: 868 Bytes

Versions: 19

Compression:

Stored size: 868 Bytes

Contents

var http = require('http')
  , assert = require('assert')
  , request = require('../index')
  ;

var portOne = 8968
  , portTwo = 8969
  ;


// server one
var s1 = http.createServer(function (req, resp) {
  if (req.url == '/original') {
    resp.writeHeader(302, {'location': '/redirected'})
    resp.end()
  } else if (req.url == '/redirected') {
    resp.writeHeader(200, {'content-type': 'text/plain'})
    resp.write('OK')
    resp.end()
  }

}).listen(portOne);


// server two
var s2 = http.createServer(function (req, resp) {
  var x = request('http://localhost:'+portOne+'/original')
  req.pipe(x)
  x.pipe(resp)

}).listen(portTwo, function () {
  var r = request('http://localhost:'+portTwo+'/original', function (err, res, body) {
    assert.equal(body, 'OK')

    s1.close()
    s2.close()
  });

  // it hangs, so wait a second :)
  r.timeout = 1000;

})

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 node_modules/request/tests/test-piped-redirect.js
ela-4.1.5 node_modules/request/tests/test-piped-redirect.js
ela-4.1.4 node_modules/request/tests/test-piped-redirect.js
ela-4.1.3 node_modules/request/tests/test-piped-redirect.js
ela-4.1.2 node_modules/request/tests/test-piped-redirect.js
ela-4.1.1 node_modules/request/tests/test-piped-redirect.js
ela-4.1.0 node_modules/request/tests/test-piped-redirect.js
ela-4.0.0 node_modules/request/tests/test-piped-redirect.js
ela-3.4.3 node_modules/request/tests/test-piped-redirect.js
ela-3.4.2 node_modules/request/tests/test-piped-redirect.js
ela-3.4.0 node_modules/request/tests/test-piped-redirect.js
ela-3.3.1 node_modules/request/tests/test-piped-redirect.js
ela-3.3.0 node_modules/request/tests/test-piped-redirect.js
ela-3.2.0 node_modules/request/tests/test-piped-redirect.js
ela-3.1.1 node_modules/request/tests/test-piped-redirect.js
ela-3.1.0 node_modules/request/tests/test-piped-redirect.js
ela-3.0.0 node_modules/request/tests/test-piped-redirect.js
ela-2.0.0 node_modules/request/tests/test-piped-redirect.js
ela-1.1.0 node_modules/request/tests/test-piped-redirect.js