summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2009-01-24 12:27:15 +0000
committerJan Lehnardt <jan@apache.org>2009-01-24 12:27:15 +0000
commitceb625242d53f52680021fa619fd7f104e091722 (patch)
treefc64fc09e3ce0fec6395f0011976d592ac70a64d /share/www
parent2422ad8d97483b908b339c0b5619e73868a1fdc7 (diff)
Guess port based on protocol if we run on standard ports and in the browser.
Closes COUCHDB-213. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@737346 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/couch_tests.js36
1 files changed, 32 insertions, 4 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index c87e01a5..01f94927 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -11,8 +11,13 @@
// the License.
// Used by replication test
-CouchDB.host = (typeof window == 'undefined' || !window) ?
- "127.0.0.1:5984" : window.location.host;
+if (typeof window == 'undefined' || !window) {
+ CouchDB.host = "127.0.0.1:5984";
+ CouchDB.inBrowser = false;
+} else {
+ CouchDB.host = window.location.host;
+ CouchDB.inBrowser = true;
+}
var tests = {
@@ -2843,9 +2848,32 @@ var tests = {
// test that /_config returns all the settings
var xhr = CouchDB.request("GET", "/_config");
var config = JSON.parse(xhr.responseText);
- var port = CouchDB.host.split(':').pop()
+
+ /*
+ if we run on standard ports, we can't extract
+ the number from the URL. Instead we try to guess
+ from the protocol what port we are running on.
+ If we can't guess, we don't test for the port.
+ Overengineering FTW.
+ */
+ var server_port = CouchDB.host.split(':');
+ if(server_port.length == 1 && CouchDB.inBrowser) {
+ var proto = window.location.protocol;
+ if(proto == "http:") {
+ port = 80;
+ }
+ if(proto == "https:") {
+ port = 443;
+ }
+ } else {
+ port = server_port.pop();
+ }
+
+ if(port) {
+ T(config.httpd.port == port);
+ }
+
T(config.couchdb.database_dir);
- T(config.httpd.port == port);
T(config.daemons.httpd);
T(config.httpd_global_handlers._config);
T(config.log.level);