mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
support forward
This commit is contained in:
parent
031aa0fbf3
commit
8c8c455541
@ -1,9 +1,7 @@
|
||||
var ForwardStream = require('../streams/forward'),
|
||||
ProxyStream = require('../streams/proxy'),
|
||||
http = require('http'),
|
||||
https = require('https'),
|
||||
common = require('../common'),
|
||||
passes = exports;
|
||||
var http = require('http'),
|
||||
https = require('https'),
|
||||
common = require('../common'),
|
||||
passes = exports;
|
||||
|
||||
/*!
|
||||
* Array of passes.
|
||||
@ -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)
|
||||
);
|
||||
|
||||
3
ttest.js
3
ttest.js
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user