Socket
Socket
Sign inDemoInstall

http-proxy

Package Overview
Dependencies
Maintainers
3
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy - npm Package Compare versions

Comparing version 0.7.0 to 0.7.2

2

examples/http/proxy-https-to-http.js

@@ -32,3 +32,3 @@ /*

httpProxy = require('../../lib/node-http-proxy'),
helpers = require('./../test/helpers');
helpers = require('../../test/helpers');

@@ -35,0 +35,0 @@ var opts = helpers.loadHttps();

@@ -32,3 +32,3 @@ /*

httpProxy = require('../../lib/node-http-proxy'),
helpers = require('./../test/helpers');
helpers = require('../../test/helpers');

@@ -57,2 +57,2 @@ var opts = helpers.loadHttps();

util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8080'.yellow);
util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow);
util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow);

@@ -35,3 +35,3 @@ /*

//
var proxy = new httpProxy.HttpProxy();
var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {

@@ -38,0 +38,0 @@ var buffer = httpProxy.buffer(req);

var Store = require('./lib/store')
var Store = require('../helpers/store')
, http = require('http')

@@ -45,3 +45,3 @@

require('http-proxy').createServer(
require('../../lib/node-http-proxy').createServer(
//refactor the body parser and re-streamer into a separate package

@@ -48,0 +48,0 @@ bodyParser(),

@@ -1,2 +0,2 @@

var Store = require('./lib/store')
var Store = require('../helpers/store')
, http = require('http')

@@ -27,5 +27,5 @@

require('http-proxy').createServer(
require('../../lib/node-http-proxy').createServer(
require('connect-jsonp')(true),
'localhost', 7531
).listen(1337)
).listen(1337)

@@ -30,3 +30,3 @@ /*

http = require('http'),
httpProxy = require('http-proxy');
httpProxy = require('../../lib/node-http-proxy');

@@ -59,2 +59,2 @@ //

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('http-proxy'),
Store = require('./lib/store')
httpProxy = require('../../lib/node-http-proxy'),
Store = require('../helpers/store')

@@ -30,2 +30,2 @@ http.createServer(new Store().handler()).listen(7531)

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);

@@ -30,3 +30,3 @@ /*

colors = require('colors'),
websocket = require('./../vendor/websocket'),
websocket = require('../../vendor/websocket'),
httpProxy = require('../../lib/node-http-proxy');

@@ -71,9 +71,11 @@

//
var proxy = new httpProxy.HttpProxy();
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res, {
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8080
})
}
});
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
});

@@ -88,7 +90,3 @@ //

setTimeout(function () {
proxy.proxyWebSocketRequest(req, socket, head, {
port: 8080,
host: 'localhost',
buffer: buffer
});
proxy.proxyWebSocketRequest(req, socket, head, buffer);
}, 1000);

@@ -95,0 +93,0 @@ });

@@ -30,3 +30,3 @@ /*

colors = require('colors'),
websocket = require('./../vendor/websocket'),
websocket = require('../../vendor/websocket'),
httpProxy = require('../../lib/node-http-proxy');

@@ -71,9 +71,11 @@

//
var proxy = new httpProxy.HttpProxy();
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res, {
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8080
})
}
});
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
});

@@ -85,6 +87,3 @@ //

proxyServer.on('upgrade', function (req, socket, head) {
proxy.proxyWebSocketRequest(req, socket, head, {
port: 8080,
host: 'localhost'
});
proxy.proxyWebSocketRequest(req, socket, head);
});

@@ -91,0 +90,0 @@

@@ -30,3 +30,3 @@ /*

colors = require('colors'),
websocket = require('./../vendor/websocket'),
websocket = require('../../vendor/websocket'),
httpProxy = require('../../lib/node-http-proxy');

@@ -33,0 +33,0 @@

@@ -131,5 +131,6 @@ /*

//
if (this.enable.xforward && req.connection && req.connection.socket) {
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
if (this.enable.xforward && req.connection && req.socket) {
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.socket.remoteAddress;
req.headers['x-forwarded-port'] = req.connection.remotePort || req.socket.remotePort;
req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';

@@ -396,3 +397,3 @@ }

//
_socket(socket);
_socket(socket, true);

@@ -667,3 +668,8 @@ //

//
// XXX This is very wrong and should be fixed in node's core
//
reverseProxy.write(head);
if (head && head.length === 0) {
reverseProxy._send('');
}
}

@@ -769,2 +775,2 @@ catch (ex) {

});
};
};
{
"name": "http-proxy",
"version": "0.7.0",
"version": "0.7.2",
"description": "A full-featured http reverse proxy for node.js",

@@ -5,0 +5,0 @@ "author": "Charlie Robbins <charlie.robbins@gmail.com>",

@@ -148,3 +148,3 @@ # node-http-proxy

//
var proxy = new httpProxy.HttpProxy();
var proxy = new httpProxy.RoutingProxy();

@@ -251,8 +251,10 @@ //

//
var proxy = new httpProxy.HttpProxy();
https.createServer(options.https, function (req, res) {
proxy.proxyRequest(req, res, {
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8000
})
}
});
https.createServer(options.https, function (req, res) {
proxy.proxyRequest(req, res)
}).listen(8002);

@@ -271,3 +273,3 @@

### Proxying to HTTPS from HTTPS
Proxying from HTTPS to HTTPS is essentially the same as proxying from HTTPS to HTTP, but you must include `target` option in when calling `httpProxy.createServer` or instantiating a new instance of `HttpProxy`.
Proxying from HTTPS to HTTPS is essentially the same as proxying from HTTPS to HTTP, but you must include the `target` option in when calling `httpProxy.createServer` or instantiating a new instance of `HttpProxy`.

@@ -299,2 +301,4 @@ ``` js

target: {
host: 'localhost',
port: 8000,
https: true

@@ -305,6 +309,3 @@ }

https.createServer(options.https, function (req, res) {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 8000
})
proxy.proxyRequest(req, res);
}).listen(8002);

@@ -333,3 +334,3 @@

## Proxying WebSockets
Websockets are handled automatically when using the `httpProxy.createServer()`, but if you want to use it in conjunction with a stand-alone HTTP + WebSocket (such as [socket.io][5]) server here's how:
Websockets are handled automatically when using `httpProxy.createServer()`, but if you want to use it in conjunction with a stand-alone HTTP + WebSocket (such as [socket.io][5]) server here's how:

@@ -343,3 +344,7 @@ ``` js

//
var proxy = new httpProxy.HttpProxy();
var proxy = new httpProxy.HttpProxy(
target: {
host: 'localhost',
port: 8000
});

@@ -350,6 +355,3 @@ var server = http.createServer(function (req, res) {

//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 8000
})
proxy.proxyRequest(req, res);
});

@@ -361,6 +363,3 @@

//
proxy.proxyWebSocketRequest(req, socket, head, {
host: 'localhost',
port: 8000
});
proxy.proxyWebSocketRequest(req, socket, head);
});

@@ -367,0 +366,0 @@ ```

@@ -131,2 +131,36 @@ /*

// A test helper to check and see if the http headers were set properly.
TestRunner.prototype.assertHeaders = function (proxyPort, headerName, createProxy) {
var assertion = "should receive http header \"" + headerName + "\"",
protocol = this.source.protocols.http;
var test = {
topic: function () {
var that = this, options = {
method: 'GET',
uri: protocol + '://localhost:' + proxyPort,
headers: {
host: 'unknown.com'
}
};
if (createProxy) {
return createProxy(function () {
request(options, that.callback);
});
}
request(options, this.callback);
}
};
test[assertion] = function (err, res, body) {
assert.isNull(err);
assert.isNotNull(res.headers[headerName]);
};
return test;
};
//

@@ -372,2 +406,2 @@ // WebSocketTest

return target;
}
}

@@ -77,4 +77,7 @@ /*

}),
"and without a valid forward server": runner.assertProxied('localhost', 8122, 8123, function (callback) {
runner.startProxyServerWithForwarding(8122, 8123, 'localhost', badForwardOptions, callback);
"and also a valid target server": runner.assertHeaders(8122, "x-forwarded-for", function (callback) {
runner.startProxyServerWithForwarding(8122, 8123, 'localhost', forwardOptions, callback);
}),
"and without a valid forward server": runner.assertProxied('localhost', 8124, 8125, function (callback) {
runner.startProxyServerWithForwarding(8124, 8125, 'localhost', badForwardOptions, callback);
})

@@ -81,0 +84,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc