diff options
author | Christopher Lenz <cmlenz@apache.org> | 2008-05-25 21:48:00 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@apache.org> | 2008-05-25 21:48:00 +0000 |
commit | 3368134b760178287f1101d403a1f0ed5caf5e23 (patch) | |
tree | 713aa382644432fc9c1b3ef9adc6592f2fc32cdb /src/couchdb | |
parent | c87220a67f5c5a69be0e6ff41b3bc2a2ba113b35 (diff) |
Enable Etag processing for document GET requests that include the '?rev' query string parameter.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@660046 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_httpd.erl | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index fcbe66a0..239fd697 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -474,31 +474,30 @@ handle_doc_request(Req, 'GET', _DbName, Db, DocId) -> 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), |