couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r660046 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
Date Sun, 25 May 2008 21:48:01 GMT
Author: cmlenz
Date: Sun May 25 14:48:00 2008
New Revision: 660046

URL: http://svn.apache.org/viewvc?rev=660046&view=rev
Log:
Enable Etag processing for document GET requests that include the '?rev' query string parameter.

Modified:
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=660046&r1=660045&r2=660046&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Sun May 25 14:48:00 2008
@@ -474,31 +474,30 @@
     case Revs of
     [] ->
         case Rev of
-        "" ->
-            % open most recent rev
+        "" -> % open most recent rev
             case couch_db:open_doc(Db, DocId, Options) of
-            {ok, #doc{revs=[DocRev|_]}=Doc} ->
-                Etag = none_match(Req, DocRev),
-                JsonDoc = couch_doc:to_json_obj(Doc, Options),
-                AdditionalHeaders =
-                    case Doc#doc.meta of
-                    [] -> [{"Etag", Etag}]; % output etag when we have no meta
-                    _ -> []
-                    end,
-                send_json(Req, 200, AdditionalHeaders, JsonDoc);
-            Error ->
-                throw(Error)
+                {ok, #doc{revs=[DocRev|_]}=Doc} ->
+                    true;
+                Error ->
+                    Doc = DocRev = undefined,
+                    throw(Error)
             end;
-        _ ->
-            % open a specific rev (deletions come back as stubs)
+        _ -> % open a specific rev (deletions come back as stubs)
             case couch_db:open_doc_revs(Db, DocId, [Rev], Options) of
-            {ok, [{ok, Doc}]} ->
-                send_json(Req, 200, [],
-                          couch_doc:to_json_obj(Doc, Options));
-            {ok, [Else]} ->
-                throw(Else)
+                {ok, [{ok, Doc}]} ->
+                    DocRev = Rev;
+                {ok, [Else]} ->
+                    Doc = DocRev = undefined,
+                    throw(Else)
             end
-        end;
+        end,
+        Etag = none_match(Req, DocRev),
+        AdditionalHeaders = case Doc#doc.meta of
+            [] -> [{"Etag", Etag}]; % output etag when we have no meta
+            _ -> []
+        end,
+        JsonDoc = couch_doc:to_json_obj(Doc, Options),
+        send_json(Req, 200, AdditionalHeaders, JsonDoc);
     _ ->
         {ok, Results} = couch_db:open_doc_revs(Db, DocId, Revs, Options),
         Resp = start_json_response(Req, 200),



Mime
View raw message