Author: jchris
Date: Fri Jun 25 05:17:30 2010
New Revision: 957799

URL: http://svn.apache.org/viewvc?rev=957799&view=rev
Log:
use proper Accept headers in the test suite

Modified:
    couchdb/trunk/share/www/script/couch.js
    couchdb/trunk/share/www/script/test/content_negotiation.js
    couchdb/trunk/share/www/script/test/list_views.js

Modified: couchdb/trunk/share/www/script/couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch.js?rev=957799&r1=957798&r2=957799&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch.js [utf-8] Fri Jun 25 05:17:30 2010
@@ -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

Modified: couchdb/trunk/share/www/script/test/content_negotiation.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/content_negotiation.js?rev=957799&r1=957798&r2=957799&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/content_negotiation.js (original)
+++ couchdb/trunk/share/www/script/test/content_negotiation.js Fri Jun 25 
05:17:30 2010
@@ -17,11 +17,14 @@ couchTests.content_negotiation = functio
   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/", {

Modified: couchdb/trunk/share/www/script/test/list_views.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/list_views.js?rev=957799&r1=957798&r2=957799&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/list_views.js (original)
+++ couchdb/trunk/share/www/script/test/list_views.js Fri Jun 25 05:17:30 2010
@@ -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


Reply via email to