You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2011/10/29 20:59:52 UTC

[2/3] git commit: Allow OPTIONS HTTP method for list requests.

Allow OPTIONS HTTP method for list requests.

Closes COUCHDB-1097

Patch by Omar Yasin.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6e077c30
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6e077c30
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6e077c30

Branch: refs/heads/1.2.x
Commit: 6e077c3026512ce58ea13c9decdd1cde0ca704d7
Parents: 5dfe9a1
Author: Jan Lehnardt <ja...@apache.org>
Authored: Sat Oct 29 20:59:20 2011 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat Oct 29 20:59:20 2011 +0200

----------------------------------------------------------------------
 THANKS                              |    1 +
 share/www/script/test/list_views.js |    4 ++++
 src/couchdb/couch_httpd_show.erl    |   13 ++++++++-----
 3 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/6e077c30/THANKS
----------------------------------------------------------------------
diff --git a/THANKS b/THANKS
index 320d744..714c224 100644
--- a/THANKS
+++ b/THANKS
@@ -90,5 +90,6 @@ suggesting improvements or submitting changes. Some of these people are:
  * Christopher Bonhage <qu...@me.com>
  * Christian Carter <cd...@gmail.com>
  * Lukasz Mielicki <mi...@gmail.com>
+ * Omar Yasin <om...@gmail.com>
 
 For a list of authors see the `AUTHORS` file.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6e077c30/share/www/script/test/list_views.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js
index c8af481..6449bd7 100644
--- a/share/www/script/test/list_views.js
+++ b/share/www/script/test/list_views.js
@@ -204,6 +204,10 @@ couchTests.list_views = function(debug) {
   T(xhr.status == 200, "standard get should be 200");
   T(/head0123456789tail/.test(xhr.responseText));
 
+  // standard options
+  var xhr = CouchDB.request("OPTIONS", "/test_suite_db/_design/lists/_list/basicBasic/basicView");
+  T(xhr.status == 200, "standard get should be 200");
+  T(/head0123456789tail/.test(xhr.responseText));
 
   // test that etags are available
   var etag = xhr.getResponseHeader("etag");

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6e077c30/src/couchdb/couch_httpd_show.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl
index be93ba8..7bb4341 100644
--- a/src/couchdb/couch_httpd_show.erl
+++ b/src/couchdb/couch_httpd_show.erl
@@ -151,18 +151,21 @@ send_doc_update_response(Req, Db, DDoc, UpdateName, Doc, DocId) ->
 
 
 % view-list request with view and list from same design doc.
-handle_view_list_req(#httpd{method='GET',
-        path_parts=[_, _, DesignName, _, ListName, ViewName]}=Req, Db, DDoc) ->
+handle_view_list_req(#httpd{method=Method,
+        path_parts=[_, _, DesignName, _, ListName, ViewName]}=Req, Db, DDoc)
+  when Method =:= 'GET' orelse Method =:= 'OPTIONS' ->
     Keys = couch_httpd:qs_json_value(Req, "keys", nil),
     handle_view_list(Req, Db, DDoc, ListName, {DesignName, ViewName}, Keys);
 
 % view-list request with view and list from different design docs.
-handle_view_list_req(#httpd{method='GET',
-        path_parts=[_, _, _, _, ListName, ViewDesignName, ViewName]}=Req, Db, DDoc) ->
+handle_view_list_req(#httpd{method=Method,
+        path_parts=[_, _, _, _, ListName, ViewDesignName, ViewName]}=Req, Db, DDoc)
+  when Method =:= 'GET' orelse Method =:= 'OPTIONS' ->
     Keys = couch_httpd:qs_json_value(Req, "keys", nil),
     handle_view_list(Req, Db, DDoc, ListName, {ViewDesignName, ViewName}, Keys);
 
-handle_view_list_req(#httpd{method='GET'}=Req, _Db, _DDoc) ->
+handle_view_list_req(#httpd{method=Method}=Req, _Db, _DDoc)
+    when Method =:= 'GET' orelse Method =:= 'OPTIONS' ->
     send_error(Req, 404, <<"list_error">>, <<"Invalid path.">>);
 
 handle_view_list_req(#httpd{method='POST',