couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nsla...@apache.org
Subject [24/30] git commit: COUCHDB-1563 ensures urlPrefix is set in all ajax requests
Date Sat, 17 Nov 2012 19:52:50 GMT
COUCHDB-1563 ensures urlPrefix is set in all ajax requests


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/07a6af22
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/07a6af22
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/07a6af22

Branch: refs/heads/docs
Commit: 07a6af222247d34c41ee8eabec9822c26a407ff8
Parents: 67ae112
Author: Keks Keksov <keksov@gmail.com>
Authored: Thu Oct 25 00:29:02 2012 +0200
Committer: Dave Cottlehuber <dch@apache.org>
Committed: Thu Oct 25 00:29:02 2012 +0200

----------------------------------------------------------------------
 share/www/script/couch.js                    |   11 ++++++++---
 share/www/script/test/changes.js             |   17 ++++++++---------
 share/www/script/test/content_negotiation.js |    2 +-
 share/www/verify_install.html                |    1 +
 4 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/07a6af22/share/www/script/couch.js
----------------------------------------------------------------------
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index f7099e3..3deb441 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -400,15 +400,20 @@ CouchDB.xhrheader = function(xhr, header) {
   }
 }
 
+CouchDB.proxyUrl = function(uri) {
+  if(uri.substr(0, CouchDB.protocol.length) != CouchDB.protocol) {
+    uri = CouchDB.urlPrefix + uri;
+  }
+  return uri;
+}
+
 CouchDB.request = function(method, uri, options) {
   options = typeof(options) == 'object' ? options : {};
   options.headers = typeof(options.headers) == 'object' ? options.headers : {};
   options.headers["Content-Type"] = options.headers["Content-Type"] || options.headers["content-type"]
|| "application/json";
   options.headers["Accept"] = options.headers["Accept"] || options.headers["accept"] || "application/json";
   var req = CouchDB.newXhr();
-  if(uri.substr(0, CouchDB.protocol.length) != CouchDB.protocol) {
-    uri = CouchDB.urlPrefix + uri;
-  }
+  uri = CouchDB.proxyUrl(uri);
   req.open(method, uri, false);
   if (options.headers) {
     var headers = options.headers;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/07a6af22/share/www/script/test/changes.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js
index 33b3af9..d76c193 100644
--- a/share/www/script/test/changes.js
+++ b/share/www/script/test/changes.js
@@ -78,7 +78,7 @@ couchTests.changes = function(debug) {
     // WebKit (last checked on nightly #47686) does fail on processing
     // the async-request properly while javascript is executed.
 
-    xhr.open("GET", "/test_suite_db/_changes?feed=continuous&timeout=500", true);
+    xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&timeout=500"),
true);
     xhr.send("");
 
     var docBar = {_id:"bar", bar:1};
@@ -122,7 +122,7 @@ couchTests.changes = function(debug) {
     xhr = CouchDB.newXhr();
 
     //verify the hearbeat newlines are sent
-    xhr.open("GET", "/test_suite_db/_changes?feed=continuous&heartbeat=10&timeout=500",
true);
+    xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&heartbeat=10&timeout=500"),
true);
     xhr.send("");
 
     var str;
@@ -169,7 +169,7 @@ couchTests.changes = function(debug) {
     // test longpolling
     xhr = CouchDB.newXhr();
 
-    xhr.open("GET", "/test_suite_db/_changes?feed=longpoll", true);
+    xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=longpoll"), true);
     xhr.send("");
 
     waitForSuccess(function() {
@@ -181,7 +181,7 @@ couchTests.changes = function(debug) {
 
     xhr = CouchDB.newXhr();
 
-    xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&since=3", true);
+    xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=longpoll&since=3"),
true);
     xhr.send("");
 
     var docBarz = {_id:"barz", bar:1};
@@ -300,13 +300,13 @@ couchTests.changes = function(debug) {
     // filter with longpoll
     // longpoll filters full history when run without a since seq
     xhr = CouchDB.newXhr();
-    xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&filter=changes_filter/bop",
false);
+    xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=longpoll&filter=changes_filter/bop"),
false);
     xhr.send("");
     var resp = JSON.parse(xhr.responseText);
     T(resp.last_seq == 8);
     // longpoll waits until a matching change before returning
     xhr = CouchDB.newXhr();
-    xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&since=8&filter=changes_filter/bop",
true);
+    xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=longpoll&since=7&filter=changes_filter/bop"),
true);
     xhr.send("");
     db.save({"_id":"falsy", "bop" : ""}); // empty string is falsy
     db.save({"_id":"bingo","bop" : "bingo"});
@@ -325,7 +325,7 @@ couchTests.changes = function(debug) {
 
       // filter with continuous
       xhr = CouchDB.newXhr();
-      xhr.open("GET", "/test_suite_db/_changes?feed=continuous&filter=changes_filter/bop&timeout="+timeout,
true);
+      xhr.open("GET", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&filter=changes_filter/bop&timeout="+timeout),
true);
       xhr.send("");
 
       db.save({"_id":"rusty", "bop" : "plankton"});
@@ -518,7 +518,7 @@ couchTests.changes = function(debug) {
     if (!is_safari && xhr) {
         // filter docids with continuous
         xhr = CouchDB.newXhr();
-        xhr.open("POST", "/test_suite_db/_changes?feed=continuous&timeout=500&since=7&filter=_doc_ids",
true);
+        xhr.open("POST", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&timeout=500&since=7&filter=_doc_ids"),
true);
         xhr.setRequestHeader("Content-Type", "application/json");
 
         xhr.send(options.body);
@@ -612,4 +612,3 @@ couchTests.changes = function(debug) {
   // cleanup
   db.deleteDb();
 };
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/07a6af22/share/www/script/test/content_negotiation.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/content_negotiation.js b/share/www/script/test/content_negotiation.js
index 5778fad..36e7dfb 100644
--- a/share/www/script/test/content_negotiation.js
+++ b/share/www/script/test/content_negotiation.js
@@ -19,7 +19,7 @@ couchTests.content_negotiation = function(debug) {
 
   // with no accept header
   var req = CouchDB.newXhr();
-  req.open("GET", "/test_suite_db/", false);
+  req.open("GET", CouchDB.proxyUrl("/test_suite_db/"), false);
   req.send("");
   TEquals("text/plain; charset=utf-8", req.getResponseHeader("Content-Type"));
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/07a6af22/share/www/verify_install.html
----------------------------------------------------------------------
diff --git a/share/www/verify_install.html b/share/www/verify_install.html
index 1806adf..388833b 100644
--- a/share/www/verify_install.html
+++ b/share/www/verify_install.html
@@ -45,6 +45,7 @@ specific language governing permissions and limitations under the License.
     }
 
     function tests() {
+      CouchDB.urlPrefix = "..";
       var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
 
       // cleanup, ignore the 404


Mime
View raw message