summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2009-02-11 16:12:39 +0000
committerDamien F. Katz <damien@apache.org>2009-02-11 16:12:39 +0000
commitfd31ca2f9ee86cafa2b55da5f969616a1e06926d (patch)
tree1f59347028521afed3e3301eaa2394981177de58 /share/www
parent59f41c2678f59a2effade9651c0de11bbe811c56 (diff)
Changed _uuid to respond to GET instead of POST. Bug COUCHDB-190
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@743373 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/couch.js2
-rw-r--r--share/www/script/couch_tests.js23
2 files changed, 20 insertions, 5 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index 96612faa..21382dd0 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -312,7 +312,7 @@ CouchDB.newUuids = function(n) {
}
return uuids;
} else {
- CouchDB.last_req = CouchDB.request("POST", "/_uuids?count=" + (100 + n));
+ CouchDB.last_req = CouchDB.request("GET", "/_uuids?count=" + (100 + n));
CouchDB.maybeThrowError(CouchDB.last_req);
var result = JSON.parse(CouchDB.last_req.responseText);
CouchDB.uuids_cache =
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 55a63bc9..e9594918 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -457,20 +457,33 @@ db.createDb();
},
uuids: function(debug) {
+ var testHashBustingHeaders = function(xhr) {
+ T(xhr.getResponseHeader("Cache-Control").match(/no-cache/));
+ T(xhr.getResponseHeader("Pragma") == "no-cache");
+
+ var currentTime = new Date();
+ var expiresHeader = Date.parse(xhr.getResponseHeader("Expires"));
+ var dateHeader = Date.parse(xhr.getResponseHeader("Date"));
+
+ T(expiresHeader < currentTime);
+ T(currentTime - dateHeader < 3000);
+ };
+
var db = new CouchDB("test_suite_db");
db.deleteDb();
db.createDb();
if (debug) debugger;
// a single UUID without an explicit count
- var xhr = CouchDB.request("POST", "/_uuids");
+ var xhr = CouchDB.request("GET", "/_uuids");
T(xhr.status == 200);
var result = JSON.parse(xhr.responseText);
T(result.uuids.length == 1);
var first = result.uuids[0];
+ testHashBustingHeaders(xhr);
// a single UUID with an explicit count
- xhr = CouchDB.request("POST", "/_uuids?count=1");
+ xhr = CouchDB.request("GET", "/_uuids?count=1");
T(xhr.status == 200);
result = JSON.parse(xhr.responseText);
T(result.uuids.length == 1);
@@ -478,7 +491,7 @@ db.createDb();
T(first != second);
// no collisions with 1,000 UUIDs
- xhr = CouchDB.request("POST", "/_uuids?count=1000");
+ xhr = CouchDB.request("GET", "/_uuids?count=1000");
T(xhr.status == 200);
result = JSON.parse(xhr.responseText);
T( result.uuids.length == 1000 );
@@ -489,7 +502,9 @@ db.createDb();
seen[id] = 1;
}
- // check our library
+ // ensure we return a 405 on POST
+ xhr = CouchDB.request("POST", "/_uuids?count=1000");
+ T(xhr.status == 405);
},
bulk_docs: function(debug) {