janl commented on a change in pull request #1253: [DISCUSS] Validate new 
document writes against max_http_request_size
URL: https://github.com/apache/couchdb/pull/1253#discussion_r178028983
 
 

 ##########
 File path: src/couch/src/couch_doc.erl
 ##########
 @@ -136,12 +136,27 @@ from_json_obj_validate(EJson, DbName) ->
     case couch_ejson_size:encoded_size(Doc#doc.body) =< MaxSize of
         true ->
              validate_attachment_sizes(Doc#doc.atts),
+             validate_total_document_size(Doc),
              Doc;
         false ->
             throw({request_entity_too_large, Doc#doc.id})
     end.
 
 
+% sum up the json body size + attachment body size and
+% make sure it is < max_http_request_size
+validate_total_document_size(#doc{id=DocId, body=Body, atts=Atts0}) ->
+    MaxReqSize = config:get_integer("httpd", "max_http_request_size", 
4294967296), % 2 GB
+    Boundary = couch_uuids:random(), % mock boundary, is only used for the 
length
 
 Review comment:
   @rnewson I wasn’t sure if the configuration could change the format of the 
uuid, that’s why I used this one, so we pick that up in current or future uuid 
format changes.
   
   Happy to chalk this off to YAGNI, just wanted to mention that this was 
intentional.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to