summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-06-25 05:17:30 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-06-25 05:17:30 +0000
commitea1ffd94840e79bac252893741e43412aaca96e6 (patch)
tree770cff04a02c61122118e3da5565c116045b7f3b /share/www
parentceada3e64c95307f863a4010a23e2cf8f6f56460 (diff)
use proper Accept headers in the test suite
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@957799 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/couch.js3
-rw-r--r--share/www/script/test/content_negotiation.js9
-rw-r--r--share/www/script/test/list_views.js12
3 files changed, 18 insertions, 6 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index d745b06e..33fd82ba 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -399,7 +399,8 @@ CouchDB.newXhr = function() {
CouchDB.request = function(method, uri, options) {
options = options || {};
options.headers = options.headers || {};
- options.headers["Content-Type"] = options.headers["Content-Type"] || "application/json";
+ 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, "http://".length) != "http://") {
uri = CouchDB.urlPrefix + uri
diff --git a/share/www/script/test/content_negotiation.js b/share/www/script/test/content_negotiation.js
index 171dbb3d..c79df948 100644
--- a/share/www/script/test/content_negotiation.js
+++ b/share/www/script/test/content_negotiation.js
@@ -17,11 +17,14 @@ couchTests.content_negotiation = function(debug) {
if (debug) debugger;
var xhr;
- xhr = CouchDB.request("GET", "/test_suite_db/");
- TEquals("text/plain;charset=utf-8", xhr.getResponseHeader("Content-Type"));
+ // with no accept header
+ var req = CouchDB.newXhr();
+ req.open("GET", "/test_suite_db/", false);
+ req.send("");
+ TEquals("text/plain;charset=utf-8", req.getResponseHeader("Content-Type"));
// make sure JSON responses end in a newline
- var text = xhr.responseText;
+ var text = req.responseText;
TEquals("\n", text[text.length-1]);
xhr = CouchDB.request("GET", "/test_suite_db/", {
diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js
index 1cb1b2ec..c72370bd 100644
--- a/share/www/script/test/list_views.js
+++ b/share/www/script/test/list_views.js
@@ -346,13 +346,21 @@ couchTests.list_views = function(debug) {
// T(xhr.getResponseHeader("Content-Type") == "text/plain");
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "basic stop");
- xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter2/basicView");
+ xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter2/basicView", {
+ headers : {
+ "Accept" : "text/html"
+ }
+ });
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "stop 2");
// aborting iteration with reduce
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter/withReduce?group=true");
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "reduce stop");
- xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter2/withReduce?group=true");
+ xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter2/withReduce?group=true", {
+ headers : {
+ "Accept" : "text/html"
+ }
+ });
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "reduce stop 2");
// with accept headers for HTML