mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
- support unix donain sockets and windows named pipes (socketPath) on node 0.8.x. On node 0.6.x the support was opaque via port, but on the new node, socketPath should be set explicitely.
- avoid adding multiple headers with the same name - fix bug in setting connection
This commit is contained in:
parent
eee6babc98
commit
ffe74ed299
@ -212,13 +212,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
|
|||||||
//
|
//
|
||||||
// Setup outgoing proxy with relevant properties.
|
// Setup outgoing proxy with relevant properties.
|
||||||
//
|
//
|
||||||
outgoing.host = this.target.host;
|
outgoing.host = this.target.host;
|
||||||
outgoing.hostname = this.target.hostname;
|
outgoing.hostname = this.target.hostname;
|
||||||
outgoing.port = this.target.port;
|
outgoing.port = this.target.port;
|
||||||
outgoing.agent = this.target.agent;
|
outgoing.socketPath = this.target.socketPath;
|
||||||
outgoing.method = req.method;
|
outgoing.agent = this.target.agent;
|
||||||
outgoing.path = req.url;
|
outgoing.method = req.method;
|
||||||
outgoing.headers = req.headers;
|
outgoing.path = req.url;
|
||||||
|
outgoing.headers = req.headers;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the changeOrigin option is specified, change the
|
// If the changeOrigin option is specified, change the
|
||||||
@ -237,7 +238,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
|
|||||||
//
|
//
|
||||||
// Process the `reverseProxy` `response` when it's received.
|
// Process the `reverseProxy` `response` when it's received.
|
||||||
//
|
//
|
||||||
if (response.headers.connection) {
|
if (!response.headers.connection) {
|
||||||
if (req.headers.connection) { response.headers.connection = req.headers.connection }
|
if (req.headers.connection) { response.headers.connection = req.headers.connection }
|
||||||
else { response.headers.connection = 'close' }
|
else { response.headers.connection = 'close' }
|
||||||
}
|
}
|
||||||
@ -281,7 +282,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Set the headers of the client response
|
// Set the headers of the client response
|
||||||
res.writeHead(response.statusCode, response.headers);
|
Object.keys(response.headers).forEach(function(key){
|
||||||
|
res.setHeader(key, response.headers[key]);
|
||||||
|
});
|
||||||
|
res.writeHead(response.statusCode);
|
||||||
|
|
||||||
// If `response.statusCode === 304`: No 'data' event and no 'end'
|
// If `response.statusCode === 304`: No 'data' event and no 'end'
|
||||||
if (response.statusCode === 304) {
|
if (response.statusCode === 304) {
|
||||||
|
|||||||
@ -85,11 +85,12 @@ RoutingProxy.prototype.add = function (options) {
|
|||||||
//
|
//
|
||||||
// TODO: Consume properties in `options` related to the `ProxyTable`.
|
// TODO: Consume properties in `options` related to the `ProxyTable`.
|
||||||
//
|
//
|
||||||
options.target = options.target || {};
|
options.target = options.target || {};
|
||||||
options.target.host = options.target.host || options.host;
|
options.target.host = options.target.host || options.host;
|
||||||
options.target.port = options.target.port || options.port;
|
options.target.port = options.target.port || options.port;
|
||||||
options.target.https = this.target && this.target.https ||
|
options.target.socketPath = options.target.socketPath || options.socketPath;
|
||||||
options.target && options.target.https;
|
options.target.https = this.target && this.target.https ||
|
||||||
|
options.target && options.target.https;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setup options to pass-thru to the new `HttpProxy` instance
|
// Setup options to pass-thru to the new `HttpProxy` instance
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user