couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1070279 - /couchdb/trunk/share/www/script/jquery.couch.js
Date Sun, 13 Feb 2011 19:17:23 GMT
Author: rnewson
Date: Sun Feb 13 19:17:22 2011
New Revision: 1070279

URL: http://svn.apache.org/viewvc?rev=1070279&view=rev
Log:
Only accept application/json from jquery.couch.js

Since Filipe's fix for parsing the accepted content types at r1041103, returns from
$.ajax could return a 302 that redirects to an HTML page. Functions like activeTasks()
expect JSON and barf when fed HTML.

Modified:
    couchdb/trunk/share/www/script/jquery.couch.js

Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=1070279&r1=1070278&r2=1070279&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Sun Feb 13 19:17:22 2011
@@ -87,6 +87,9 @@
       options = options || {};
       $.ajax({
         type: "GET", url: this.urlPrefix + "/_session",
+        beforeSend: function(xhr) {
+            xhr.setRequestHeader('Accept', 'application/json');
+        },
         complete: function(req) {
           var resp = httpData(req, "json");
           if (req.status == 200) {
@@ -123,6 +126,9 @@
       $.ajax({
         type: "POST", url: this.urlPrefix + "/_session", dataType: "json",
         data: {name: options.name, password: options.password},
+        beforeSend: function(xhr) {
+            xhr.setRequestHeader('Accept', 'application/json');
+        },
         complete: function(req) {
           var resp = httpData(req, "json");
           if (req.status == 200) {
@@ -140,6 +146,9 @@
       $.ajax({
         type: "DELETE", url: this.urlPrefix + "/_session", dataType: "json",
         username : "_", password : "_",
+        beforeSend: function(xhr) {
+            xhr.setRequestHeader('Accept', 'application/json');
+        },
         complete: function(req) {
           var resp = httpData(req, "json");
           if (req.status == 200) {
@@ -659,6 +668,7 @@
       var commit = options.ensure_full_commit;
       delete options.ensure_full_commit;
       return function(xhr) {
+        xhr.setRequestHeader('Accept', 'application/json');
         xhr.setRequestHeader("X-Couch-Full-Commit", commit.toString());
       };
     }



Mime
View raw message