Repository: couchdb Updated Branches: refs/heads/master af593514c -> 08d25e979
Fauxton: Upgrade node-http-proxy Some modifications have to be made because the API changed when the module reached v1.0 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/08d25e97 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/08d25e97 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/08d25e97 Branch: refs/heads/master Commit: 08d25e979bd64d0835a6a07c16e201d5749af498 Parents: af59351 Author: Michaël Zasso <[email protected]> Authored: Wed Jul 2 13:42:23 2014 +0200 Committer: Robert Kowalski <[email protected]> Committed: Wed Jul 2 16:31:46 2014 +0200 ---------------------------------------------------------------------- src/fauxton/Gruntfile.js | 9 +-------- src/fauxton/package.json | 2 +- src/fauxton/tasks/couchserver.js | 16 +++++++++------- 3 files changed, 11 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/08d25e97/src/fauxton/Gruntfile.js ---------------------------------------------------------------------- diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js index 8ffb2f8..047962e 100644 --- a/src/fauxton/Gruntfile.js +++ b/src/fauxton/Gruntfile.js @@ -124,14 +124,7 @@ module.exports = function(grunt) { dist: './dist/debug/', port: 8000, proxy: { - target: { - host: 'localhost', - port: 5984, - https: false - }, - // This sets the Host header in the proxy so that you can use external - // CouchDB instances and not have the Host set to 'localhost' - changeOrigin: true + target: "http://localhost:5984/" } }; http://git-wip-us.apache.org/repos/asf/couchdb/blob/08d25e97/src/fauxton/package.json ---------------------------------------------------------------------- diff --git a/src/fauxton/package.json b/src/fauxton/package.json index d84c881..a955892 100644 --- a/src/fauxton/package.json +++ b/src/fauxton/package.json @@ -27,7 +27,7 @@ "underscore": "~1.4.2", "url": "~0.7.9", "urls": "~0.0.3", - "http-proxy": "~0.10.2", + "http-proxy": "~1.1.4", "send": "~0.1.1", "grunt-mocha-phantomjs": "~0.3.0" }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/08d25e97/src/fauxton/tasks/couchserver.js ---------------------------------------------------------------------- diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js index 8e95c5c..3e82e98 100644 --- a/src/fauxton/tasks/couchserver.js +++ b/src/fauxton/tasks/couchserver.js @@ -19,6 +19,7 @@ module.exports = function (grunt) { http = require("http"), httpProxy = require('http-proxy'), send = require('send'), + urlLib = require('url'), options = grunt.config('couchserver'), _ = grunt.util._; @@ -30,18 +31,14 @@ module.exports = function (grunt) { // Proxy options with default localhost var proxy_settings = options.proxy || { - target: { - host: 'localhost', - port: 5984, - https: false - } + target: "http://localhost:5984/" }; // inform grunt that this task is async var done = this.async(); // create proxy to couch for all couch requests - var proxy = new httpProxy.HttpProxy(proxy_settings); + var proxy = httpProxy.createServer(proxy_settings); http.createServer(function (req, res) { var url = req.url.replace('app/',''), @@ -97,7 +94,12 @@ module.exports = function (grunt) { .pipe(res); } - proxy.proxyRequest(req, res); + // This sets the Host header in the proxy so that one can use external + // CouchDB instances and not have the Host set to 'localhost' + var urlObj = urlLib.parse(req.url); + req.headers['host'] = urlObj.host; + + proxy.web(req, res); }).listen(port); // Fail this task if any errors have been logged
