couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r742217 - in /couchdb/trunk: share/server/main.js src/couchdb/couch_httpd_view.erl
Date Mon, 09 Feb 2009 00:57:26 GMT
Author: jchris
Date: Mon Feb  9 00:57:26 2009
New Revision: 742217

URL: http://svn.apache.org/viewvc?rev=742217&view=rev
Log:
allow format query param to override accept headers for _list and _show

Modified:
    couchdb/trunk/share/server/main.js
    couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/share/server/main.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/server/main.js?rev=742217&r1=742216&r2=742217&view=diff
==============================================================================
--- couchdb/trunk/share/server/main.js [utf-8] (original)
+++ couchdb/trunk/share/server/main.js [utf-8] Mon Feb  9 00:57:26 2009
@@ -142,7 +142,7 @@
 // this function provides a shortcut for managing responses by Accept header
 respondWith = function(req, responders) {
   var bestKey = null, accept = req.headers["Accept"];
-  if (accept) {
+  if (accept && !req.query.format) {
     var provides = [];
     for (key in responders) {
       if (mimesByKey[key]) {
@@ -151,6 +151,8 @@
     }
     var bestMime = Mimeparse.bestMatch(provides, accept);
     bestKey = keysByMime[bestMime];
+  } else {
+    bestKey = req.query.format;
   }
   var rFunc = responders[bestKey || responders.fallback || "html"];
   if (rFunc) {      

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=742217&r1=742216&r2=742217&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Mon Feb  9 00:57:26 2009
@@ -328,6 +328,9 @@
                 Msg1 = "Bad URL query value for 'include_docs' expected \"true\" or \"false\".",
                 throw({query_parse_error, Msg1})
             end;
+        {"format", _} ->
+            % we just ignore format, so that JS can have it
+            Args;
         _ -> % unknown key
             Msg = lists:flatten(io_lib:format(
                 "Bad URL query key:~s", [Key])),



Mime
View raw message