Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb-chttpd/pull/114#discussion_r59994845
--- Diff: src/chttpd_db.erl ---
@@ -1628,6 +1634,34 @@ bulk_get_open_doc_revs1(Db, Props, _, {DocId, Revs,
Options}) ->
{DocId, Results, Options}
end.
+remove_exceed_docs(DocArray0) ->
+ MaxSize = list_to_integer(config:get("couchdb",
+ "single_max_doc_size", "1048576")),
+ {ExceedDocs, DocsArray} = lists:splitwith(fun (Doc) ->
+ exceed_doc_size(Doc, MaxSize)
+ end, DocArray0),
+ ExceedErrs = lists:map (fun ({Doc}) ->
+ DocId = case couch_util:get_value(<<"_id">>, Doc) of
+ undefined -> couch_uuids:new();
+ Id0 -> Id0
+ end,
+ Reason = lists:concat(["Document exceeded single_max_doc_size:",
+ " of ", MaxSize, " bytes"]),
+ {[{id, DocId}, {error, <<"too_large">>},
+ {reason, ?l2b(Reason)}]}
+ end, ExceedDocs),
+ {ExceedErrs, DocsArray}.
+
+exceed_doc_size(JsonBody, MaxSize) ->
+ size(term_to_binary(JsonBody)) > MaxSize.
--- End diff --
I guess, without `?JSON_ENCODE` there is no since your size will be
different for unicode data at least.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---