You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2014/07/11 23:29:39 UTC
[8/9] fauxton commit: updated refs/heads/import-master to 0ec46e9
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-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/5893a971
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/5893a971
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/5893a971
Branch: refs/heads/import-master
Commit: 5893a97156b24407f759094f485f54b8a25b5ef3
Parents: e4b218b
Author: Michaƫl Zasso <mi...@gmail.com>
Authored: Wed Jul 2 13:42:23 2014 +0200
Committer: Robert Kowalski <ro...@kowalski.gd>
Committed: Wed Jul 2 16:31:46 2014 +0200
----------------------------------------------------------------------
Gruntfile.js | 9 +--------
package.json | 2 +-
tasks/couchserver.js | 16 +++++++++-------
3 files changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/5893a971/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 8ffb2f8..047962e 100644
--- a/Gruntfile.js
+++ b/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-fauxton/blob/5893a971/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index d84c881..a955892 100644
--- a/package.json
+++ b/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-fauxton/blob/5893a971/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/tasks/couchserver.js b/tasks/couchserver.js
index 8e95c5c..3e82e98 100644
--- a/tasks/couchserver.js
+++ b/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