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,9 +1,7 @@
var ForwardStream = require('../streams/forward'), var http = require('http'),
ProxyStream = require('../streams/proxy'), https = require('https'),
http = require('http'), common = require('../common'),
https = require('https'), passes = exports;
common = require('../common'),
passes = exports;
/*! /*!
* Array of passes. * Array of passes.
@ -87,6 +85,14 @@ function XHeaders(req, res, options) {
*/ */
function stream(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( var proxyReq = (options.ssl ? https : http).request(
common.setupOutgoing(options.ssl || {}, options, req) common.setupOutgoing(options.ssl || {}, options, req)
); );

View File

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