summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_httpd_db.erl11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 4fea824b..3945498d 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -708,9 +708,14 @@ db_doc_req(#httpd{method='POST'}=Req, Db, DocId) ->
throw({bad_ctype, <<"Invalid Content-Type header for form upload">>})
end,
Form = couch_httpd:parse_form(Req),
- Rev = couch_doc:parse_rev(list_to_binary(proplists:get_value("_rev", Form))),
- {ok, [{ok, Doc}]} = couch_db:open_doc_revs(Db, DocId, [Rev], []),
-
+ case proplists:is_defined("_doc", Form) of
+ true ->
+ Json = ?JSON_DECODE(proplists:get_value("_doc", Form)),
+ Doc = couch_doc_from_req(Req, DocId, Json);
+ false ->
+ Rev = couch_doc:parse_rev(list_to_binary(proplists:get_value("_rev", Form))),
+ {ok, [{ok, Doc}]} = couch_db:open_doc_revs(Db, DocId, [Rev], [])
+ end,
UpdatedAtts = [
#att{name=validate_attachment_name(Name),
type=list_to_binary(ContentType),