You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2008/04/15 02:05:41 UTC
svn commit: r648073 - in /incubator/couchdb/branches/mochiweb/src/couchdb:
couch_db.erl couch_doc.erl couch_httpd.erl
Author: damien
Date: Mon Apr 14 17:05:40 2008
New Revision: 648073
URL: http://svn.apache.org/viewvc?rev=648073&view=rev
Log:
mochiweb work. All tests pass, but seeing strange crash on the erlang console.
Modified:
incubator/couchdb/branches/mochiweb/src/couchdb/couch_db.erl
incubator/couchdb/branches/mochiweb/src/couchdb/couch_doc.erl
incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
Modified: incubator/couchdb/branches/mochiweb/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/mochiweb/src/couchdb/couch_db.erl?rev=648073&r1=648072&r2=648073&view=diff
==============================================================================
--- incubator/couchdb/branches/mochiweb/src/couchdb/couch_db.erl (original)
+++ incubator/couchdb/branches/mochiweb/src/couchdb/couch_db.erl Mon Apr 14 17:05:40 2008
@@ -607,7 +607,7 @@
Doc = make_doc(Db, Id, IsDeleted, Sp, [Rev]),
{ok, Doc#doc{meta=doc_meta_info(DocInfo, [], Options)}};
open_doc_int(Db, #full_doc_info{id=Id,rev_tree=RevTree}=FullDocInfo, Options) ->
- #doc_info{deleted=IsDeleted,rev=Rev, summary_pointer=Sp} = DocInfo =
+ #doc_info{deleted=IsDeleted,rev=Rev,summary_pointer=Sp} = DocInfo =
couch_doc:to_doc_info(FullDocInfo),
{[{_Rev,_Value, Revs}], []} = couch_key_tree:get(RevTree, [Rev]),
Doc = make_doc(Db, Id, IsDeleted, Sp, Revs),
Modified: incubator/couchdb/branches/mochiweb/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/mochiweb/src/couchdb/couch_doc.erl?rev=648073&r1=648072&r2=648073&view=diff
==============================================================================
--- incubator/couchdb/branches/mochiweb/src/couchdb/couch_doc.erl (original)
+++ incubator/couchdb/branches/mochiweb/src/couchdb/couch_doc.erl Mon Apr 14 17:05:40 2008
@@ -128,13 +128,12 @@
[{RevId, {IsDeleted, SummaryPointer}, _Path} | Rest] = SortedLeafRevs,
{ConflictRevTuples, DeletedConflictRevTuples} =
- lists:splitwith(fun({_ConflictRevId, {IsDeleted1, _SummaryPointer}, _}) ->
+ lists:splitwith(fun({_ConflictRevId, {IsDeleted1, _Sp}, _}) ->
not IsDeleted1
end, Rest),
ConflictRevs = [RevId1 || {RevId1, _, _} <- ConflictRevTuples],
DeletedConflictRevs = [RevId2 || {RevId2, _, _} <- DeletedConflictRevTuples],
-
#doc_info{
id=Id,
update_seq=Seq,
Modified: incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl?rev=648073&r1=648072&r2=648073&view=diff
==============================================================================
--- incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl Mon Apr 14 17:05:40 2008
@@ -272,7 +272,7 @@
handle_db_request(_Req, _Method, {_DbName, _Db, ["_all_docs"]}) ->
throw({method_not_allowed, "GET,HEAD"});
-handle_db_request(Req, 'GET', {_DbName, Db, ["_all_docs_by_update_seq"]}) ->
+handle_db_request(Req, 'GET', {_DbName, Db, ["_all_docs_by_seq"]}) ->
#view_query_args{
start_key = StartKey,
count = Count,
@@ -318,7 +318,7 @@
end, {Count, SkipCount, undefined, []}),
finish_view_fold(Req, {ok, TotalRowCount, FoldResult});
-handle_db_request(_Req, _Method, {_DbName, _Db, ["_all_docs_by_update_seq"]}) ->
+handle_db_request(_Req, _Method, {_DbName, _Db, ["_all_docs_by_seq"]}) ->
throw({method_not_allowed, "GET,HEAD"});
handle_db_request(Req, 'GET', {DbName, _Db, ["_view", DocId, ViewName]}) ->
@@ -339,7 +339,7 @@
handle_db_request(_Req, _Method, {_DbName, _Db, ["_view", _DocId, _ViewName]}) ->
throw({method_not_allowed, "GET,HEAD"});
-handle_db_request(Req, 'GET', {_DbName, Db, ["_missing_revs"]}) ->
+handle_db_request(Req, 'POST', {_DbName, Db, ["_missing_revs"]}) ->
{obj, JsonDocIdRevs} = cjson:decode(Req:recv_body()),
DocIdRevs = [{Id, tuple_to_list(Revs)} || {Id, Revs} <- JsonDocIdRevs],
{ok, Results} = couch_db:get_missing_revs(Db, DocIdRevs),
@@ -428,7 +428,12 @@
{ok, #doc{revs=[DocRev|_]}=Doc} ->
Etag = none_match(Req, DocRev),
JsonDoc = couch_doc:to_json_obj(Doc, Options),
- send_json(Req, 200, [{"Etag", Etag}], JsonDoc);
+ 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)
end;
@@ -436,7 +441,7 @@
% 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, [{"Etag", "\"" ++ Rev ++ "\""}],
+ send_json(Req, 200, [],
couch_doc:to_json_obj(Doc, Options));
{ok, [Else]} ->
throw(Else)