Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2BD71115BA for ; Wed, 2 Jul 2014 14:33:31 +0000 (UTC) Received: (qmail 37573 invoked by uid 500); 2 Jul 2014 14:33:31 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 37529 invoked by uid 500); 2 Jul 2014 14:33:31 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 37519 invoked by uid 99); 2 Jul 2014 14:33:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jul 2014 14:33:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9F0C69937E8; Wed, 2 Jul 2014 14:33:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: robertkowalski@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: couchdb commit: updated refs/heads/master to 08d25e9 Date: Wed, 2 Jul 2014 14:33:30 +0000 (UTC) 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 Authored: Wed Jul 2 13:42:23 2014 +0200 Committer: Robert Kowalski 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