Commit cfddd12e authored by indexzero's avatar indexzero

[api] Update `.proxyRequest()` and `.proxyWebSocketRequest()` APIs to take an...

[api] Update `.proxyRequest()` and `.proxyWebSocketRequest()` APIs to take an options hash instead of a set of arguments. Add HTTPS support.
parent 6e4bf6a9
......@@ -35,7 +35,11 @@ var util = require('util'),
httpProxy.createServer(function (req, res, proxy) {
var buffer = proxy.buffer(req);
setTimeout(function() {
proxy.proxyRequest(req, res, 9000, 'localhost', buffer);
proxy.proxyRequest(req, res, {
port: 9000,
host: 'localhost',
buffer: buffer
});
}, 200)
}).listen(8002);
......
......@@ -36,7 +36,11 @@ var proxy = new httpProxy.HttpProxy();
http.createServer(function (req, res) {
var buffer = proxy.buffer(req);
setTimeout(function() {
proxy.proxyRequest(req, res, 9000, 'localhost', buffer);
proxy.proxyRequest(req, res, {
port: 9000,
host: 'localhost',
buffer: buffer
});
}, 200);
}).listen(8004);
......
This diff is collapsed.
......@@ -100,10 +100,14 @@ TestRunner.prototype.startProxyServer = function (port, targetPort, host, callba
TestRunner.prototype.startLatentProxyServer = function (port, targetPort, host, latency, callback) {
// Initialize the nodeProxy and start proxying the request
var that = this, proxyServer = httpProxy.createServer(function (req, res, proxy) {
var data = proxy.buffer(req);
var buffer = proxy.buffer(req);
setTimeout(function () {
proxy.proxyRequest(req, res, targetPort, host, data);
proxy.proxyRequest(req, res, {
port: targetPort,
host: host,
buffer: buffer
});
}, latency);
});
......@@ -135,7 +139,9 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
proxyServer = http.createServer(function (req, res) {
var buffer = proxy.buffer(req);
setTimeout(function () {
proxy.proxyRequest(req, res, buffer);
proxy.proxyRequest(req, res, {
buffer: buffer
});
}, latency);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment