summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-proxy.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-http-proxy.js')
-rw-r--r--test/parallel/test-http-proxy.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/test/parallel/test-http-proxy.js b/test/parallel/test-http-proxy.js
index aec8eaa14c..43feb1e3b3 100644
--- a/test/parallel/test-http-proxy.js
+++ b/test/parallel/test-http-proxy.js
@@ -1,12 +1,9 @@
'use strict';
-var common = require('../common');
+require('../common');
var assert = require('assert');
var http = require('http');
var url = require('url');
-var PROXY_PORT = common.PORT;
-var BACKEND_PORT = common.PORT + 1;
-
var cookies = [
'session_token=; path=/; expires=Sun, 15-Sep-2030 13:48:52 GMT',
'prefers_open_id=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT'
@@ -26,7 +23,7 @@ var backend = http.createServer(function(req, res) {
var proxy = http.createServer(function(req, res) {
console.error('proxy req headers: ' + JSON.stringify(req.headers));
http.get({
- port: BACKEND_PORT,
+ port: backend.address().port,
path: url.parse(req.url).pathname
}, function(proxy_res) {
@@ -57,7 +54,7 @@ function startReq() {
if (nlistening < 2) return;
http.get({
- port: PROXY_PORT,
+ port: proxy.address().port,
path: '/test'
}, function(res) {
console.error('got res');
@@ -79,10 +76,10 @@ function startReq() {
}
console.error('listen proxy');
-proxy.listen(PROXY_PORT, startReq);
+proxy.listen(0, startReq);
console.error('listen backend');
-backend.listen(BACKEND_PORT, startReq);
+backend.listen(0, startReq);
process.on('exit', function() {
assert.equal(body, 'hello world\n');