Commit 56003b52 authored by Fedor Indutny's avatar Fedor Indutny

Added support of automatic websocket tunneling, added test for it

parent cd78af5f
......@@ -60,9 +60,17 @@ exports.createServer = function () {
}
});
// WebSocket support
server.on('update', function() {
});
// If callback is empty - tunnel websocket request automatically
if (!callback) {
// WebSocket support
server.on('upgrade', function(req, socket, head) {
var proxy = new HttpProxy(req, socket, head);
// Tunnel websocket requests too
proxy.proxyWebSocketRequest(port, host);
});
}
return server;
};
......@@ -325,12 +333,12 @@ HttpProxy.prototype = {
request.end();
socket.end();
}
// Catch socket errors
socket.on('error', function() {
request.end();
});
// Remove data listener
request.socket.removeListener('data', t);
});
......@@ -344,7 +352,7 @@ HttpProxy.prototype = {
}
self.unwatch(socket);
});
// Request
function onUpgrade(reverse_proxy) {
......
......@@ -48,4 +48,7 @@ server.on('upgrade', function(req, socket, head) {
p.proxyWebSocketRequest(8080, 'localhost');
});
server.listen(80);
server.listen(8000);
httpProxy.createServer(8080, 'localhost').listen(8001);
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