support forward

This commit is contained in:
yawnt 2013-09-14 14:00:31 +02:00
parent 031aa0fbf3
commit 8c8c455541
2 changed files with 14 additions and 7 deletions

View File

@ -1,6 +1,4 @@
var ForwardStream = require('../streams/forward'),
ProxyStream = require('../streams/proxy'),
http = require('http'),
var http = require('http'),
https = require('https'),
common = require('../common'),
passes = exports;
@ -87,6 +85,14 @@ function XHeaders(req, res, options) {
*/
function stream(req, res, options) {
if(options.forward) {
var forwardReq = (options.ssl ? https : http).request(
common.setupOutgoing(options.ssl || {}, options, req, 'forward')
);
req.pipe(forwardReq);
return res.end();
}
var proxyReq = (options.ssl ? https : http).request(
common.setupOutgoing(options.ssl || {}, options, req)
);

View File

@ -32,13 +32,14 @@ client.on('open', function() {
caronte.createProxyServer({
ws : true,
target: 'http://127.0.0.1:9090'
forward: 'http://127.0.0.1:9090'
}).listen(8080);
var srv = http.createServer(function(req, res) {
res.end('ciao proxy');
console.log('suca');
}).listen(9090);
/*
srv.on('upgrade', function(req, sock, head) {