From 3bbbbf14522cbd95f2a0f6610b8b6af5ebb6c778 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Mon, 26 May 2008 12:47:00 +0000 Subject: * Respond to DELETE requests with a "200 OK" status code instead of "202 Accepted", as the deletion is performed immediately. * The "content-type" member in attachment structures is now named "content_type" (underscore) for consistency and to be more accessible from Javascript (and presumably other languages, too) git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@660176 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_doc.erl | 15 ++++++++++----- src/couchdb/couch_httpd.erl | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/couchdb') diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl index cb70a576..9b7d6db9 100644 --- a/src/couchdb/couch_doc.erl +++ b/src/couchdb/couch_doc.erl @@ -51,8 +51,10 @@ to_json_obj(#doc{id=Id,deleted=Del,body=Body,revs=Revs,meta=Meta}=Doc,Options)-> true -> % return the full rev list and the binaries as strings. BinProps = lists:map( fun({Name, {Type, BinValue}}) -> - {Name, {obj, [{"content-type", Type}, - {"data", couch_util:encodeBase64(bin_to_binary(BinValue))}]}} + {Name, {obj, [ + {"content_type", Type}, + {"data", couch_util:encodeBase64(bin_to_binary(BinValue))} + ]}} end, Doc#doc.attachments), case BinProps of @@ -62,8 +64,11 @@ to_json_obj(#doc{id=Id,deleted=Del,body=Body,revs=Revs,meta=Meta}=Doc,Options)-> false -> BinProps = lists:map( fun({Name, {Type, BinValue}}) -> - {Name, {obj, [{"stub", true}, {"content-type", Type}, - {"length", bin_size(BinValue)}]}} + {Name, {obj, [ + {"stub", true}, + {"content_type", Type}, + {"length", bin_size(BinValue)} + ]}} end, Doc#doc.attachments), case BinProps of @@ -81,7 +86,7 @@ from_json_obj({obj, Props}) -> [{Name, stub}]; _ -> Value = proplists:get_value("data", BinProps), - Type = proplists:get_value("content-type", BinProps, + Type = proplists:get_value("content_type", BinProps, ?DEFAULT_ATTACHMENT_CONTENT_TYPE), [{Name, {Type, couch_util:decodeBase64(Value)}}] end diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 7174a145..26bb0915 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -164,7 +164,7 @@ handle_db_request(Req, Method, {DbName, Rest}) -> handle_db_request(Req, 'DELETE', {DbName, _Db, []}) -> ok = couch_server:delete(DbName), - send_json(Req, 202, {obj, [ + send_json(Req, 200, {obj, [ {ok, true} ]}); @@ -451,7 +451,7 @@ handle_doc_request(Req, 'DELETE', _DbName, Db, DocId) -> throw({bad_request, "Document rev and etag have different values"}) end, {ok, NewRev} = couch_db:delete_doc(Db, DocId, [RevToDelete]), - send_json(Req, 202, {obj, [ + send_json(Req, 200, {obj, [ {ok, true}, {id, DocId}, {rev, NewRev} -- cgit v1.2.3