From 152d258ea00dddfaed28ef934c540169899c1736 Mon Sep 17 00:00:00 2001 From: koichik Date: Fri, 7 Oct 2011 20:37:15 +0900 Subject: [PATCH 1/7] [fix] Avoid `Transfer-Encoding: chunked` for HTTP/1.0 client, closes #59. --- lib/node-http-proxy/http-proxy.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 35ddb3d..6c77ac6 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -210,6 +210,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { else { response.headers.connection = 'close' } } + // Remove `Transfer-Encoding` header if client's protocol is HTTP/1.0 + if (req.httpVersion === '1.0') { + delete response.headers['transfer-encoding']; + } + // Set the headers of the client response res.writeHead(response.statusCode, response.headers); From d6ea3a425c203695394eaba4ce8abd57f7809e98 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 14 Nov 2011 16:56:10 +0100 Subject: [PATCH 2/7] don't add upgrade handler if a custom handler is passed in if a callback but no static proxy is defined and no routes are provided then handlers.length is 1. However the upgrade event is still automagically attached in spite of having an explicit callback. --- lib/node-http-proxy.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index 7b3d3be..c0c85a5 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -57,6 +57,7 @@ var HttpProxy = exports.HttpProxy = require('./node-http-proxy/http-proxy' exports.createServer = function () { var args = Array.prototype.slice.call(arguments), handlers = [], + callback, options = {}, message, handler, @@ -77,7 +78,7 @@ exports.createServer = function () { case 'string': host = arg; break; case 'number': port = arg; break; case 'object': options = arg || {}; break; - case 'function': handlers.push(arg); break; + case 'function': callback = arg; handlers.push(callback); break; }; }); @@ -180,7 +181,7 @@ exports.createServer = function () { proxy.close(); }); - if (handlers.length <= 1) { + if (!callback) { // // If an explicit callback has not been supplied then // automagically proxy the request using the `HttpProxy` From 2061c713664b044852fdf67aa5e173e5c3b6d874 Mon Sep 17 00:00:00 2001 From: Cloud9 Date: Mon, 14 Nov 2011 16:18:09 +0000 Subject: [PATCH 3/7] Revert "update outgoing.headers.host incase the destination does proxying" This reverts commit 65b7872e6ad433deae4de823c63629cb341bd649. --- lib/node-http-proxy/http-proxy.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 6c77ac6..7724ddb 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -195,8 +195,6 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { outgoing.path = req.url; outgoing.headers = req.headers; - if(this.changeOrigin) - outgoing.headers.host = this.target.host + (this.target.port == 80 ? '' : ':' + this.target.port) // // Open new HTTP request to internal resource with will act // as a reverse proxy pass From c03a450d9b952e1463ae2609303029e317ff5da2 Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Sat, 15 Oct 2011 18:43:45 -0700 Subject: [PATCH 4/7] simplify proxytable path segment rewrite logic --- lib/node-http-proxy/proxy-table.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/node-http-proxy/proxy-table.js b/lib/node-http-proxy/proxy-table.js index 4ab6690..d93f082 100644 --- a/lib/node-http-proxy/proxy-table.js +++ b/lib/node-http-proxy/proxy-table.js @@ -138,14 +138,12 @@ ProxyTable.prototype.getProxyLocation = function (req) { var route = this.routes[i]; if (target.match(route.route)) { - var segments = route.path.split('/'); + var pathSegments = route.path.split('/'); - if (segments.length > 0) { - var lastSegment = new RegExp("/" + segments[segments.length - 1] + "$"); - - if(req.url.match(lastSegment)) { - req.url = req.url.replace(lastSegment, '/'); - } + if (pathSegments.length > 0) { + // don't include the proxytable path segments in the proxied request url + pathSegments = new RegExp("/" + pathSegments.slice(1).join('/')); + req.url = req.url.replace(pathSegments, ''); } var location = route.target.split(':'), From 3ab02f3ad7f2c59d73c621695eb238233c16d09c Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Wed, 16 Nov 2011 19:15:45 -0800 Subject: [PATCH 5/7] [fix] Fix incorrect depth check. --- lib/node-http-proxy/proxy-table.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node-http-proxy/proxy-table.js b/lib/node-http-proxy/proxy-table.js index d93f082..0cdce50 100644 --- a/lib/node-http-proxy/proxy-table.js +++ b/lib/node-http-proxy/proxy-table.js @@ -140,7 +140,7 @@ ProxyTable.prototype.getProxyLocation = function (req) { var pathSegments = route.path.split('/'); - if (pathSegments.length > 0) { + if (pathSegments.length > 1) { // don't include the proxytable path segments in the proxied request url pathSegments = new RegExp("/" + pathSegments.slice(1).join('/')); req.url = req.url.replace(pathSegments, ''); @@ -170,4 +170,4 @@ ProxyTable.prototype.close = function () { if (typeof this.routeFile === 'string') { fs.unwatchFile(this.routeFile); } -}; \ No newline at end of file +}; From 30dac898f30a8508b4c4b4236e9438987f320167 Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Tue, 22 Nov 2011 11:01:52 -0800 Subject: [PATCH 6/7] [dist] Adjusted engines field to allow for 0.6; version bump 0.7.7 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 775c029..03fa268 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "http-proxy", - "version": "0.7.6", + "version": "0.7.7", "description": "A full-featured http reverse proxy for node.js", "author": "Charlie Robbins ", "contributors": [ @@ -31,5 +31,5 @@ "test-http": "vows --spec && vows --spec --target=secure", "test-https": "vows --spec --source=secure && vows --spec --source=secure --target=secure" }, - "engines": { "node": "0.4.x || 0.5.x" } + "engines": { "node": ">=0.4.x <0.7.0" } } From 1e33434fcc4772c233825b5aada7472113c0be50 Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Sat, 26 Nov 2011 10:10:24 -0800 Subject: [PATCH 7/7] Revert "[dist] Adjusted engines field to allow for 0.6; version bump 0.7.7" This reverts commit 30dac898f30a8508b4c4b4236e9438987f320167. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 03fa268..775c029 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "http-proxy", - "version": "0.7.7", + "version": "0.7.6", "description": "A full-featured http reverse proxy for node.js", "author": "Charlie Robbins ", "contributors": [ @@ -31,5 +31,5 @@ "test-http": "vows --spec && vows --spec --target=secure", "test-https": "vows --spec --source=secure && vows --spec --source=secure --target=secure" }, - "engines": { "node": ">=0.4.x <0.7.0" } + "engines": { "node": "0.4.x || 0.5.x" } }