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'),
|
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)
|
||||||
);
|
);
|
||||||
|
|||||||
3
ttest.js
3
ttest.js
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user