summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-02-09 00:57:26 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-02-09 00:57:26 +0000
commit3d5351adb31fea59400179f85fb2dd97b7028ddb (patch)
treefec90683ec159379d77401d7ce7c274a81a5c83d
parent58e040359fa8d175b9eecec49f58e3dd00c78d1e (diff)
allow format query param to override accept headers for _list and _show
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@742217 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/server/main.js4
-rw-r--r--src/couchdb/couch_httpd_view.erl3
2 files changed, 6 insertions, 1 deletions
diff --git a/share/server/main.js b/share/server/main.js
index 2bbf1638..13e85ed8 100644
--- a/share/server/main.js
+++ b/share/server/main.js
@@ -142,7 +142,7 @@ var Mimeparse = (function() {
// 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 @@ respondWith = function(req, responders) {
}
var bestMime = Mimeparse.bestMatch(provides, accept);
bestKey = keysByMime[bestMime];
+ } else {
+ bestKey = req.query.format;
}
var rFunc = responders[bestKey || responders.fallback || "html"];
if (rFunc) {
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index fc3302d7..7666da98 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -328,6 +328,9 @@ parse_view_query(Req, Keys, IsReduce) ->
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])),