Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISCUSS] Validate new document writes against max_http_request_size #1253

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
janl committed Mar 29, 2018
commit ee70b5698f880ade0cd60b6a445ac80171952018
2 changes: 2 additions & 0 deletions rel/overlay/etc/local.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
[query_servers]
;nodejs = /usr/local/bin/couchjs-node /path/to/couchdb/share/server/main.js

[log]
level = debug

[httpd_global_handlers]
;_google = {couch_httpd_proxy, handle_proxy_req, <<"http:https://www.google.com">>}
Expand Down
3 changes: 2 additions & 1 deletion src/couch/src/couch_doc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ from_json_obj_validate(EJson, DbName) ->

% 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}) ->
validate_total_document_size(#doc{id=DocId, body=Body, atts=Atts0}=Doc) ->
couch_log:debug("~nData: ~p~n", [Doc]),
MaxReqSize = config:get_integer("httpd", "max_http_request_size", 4294967296), % 2 GB
Boundary = couch_uuids:random(), % mock boundary, is only used for the length
wohali marked this conversation as resolved.
Show resolved Hide resolved
Atts = lists:map(fun couch_att:to_tuple/1, Atts0),
Expand Down
3 changes: 2 additions & 1 deletion test/javascript/tests/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ couchTests.attachments= function(debug) {
_attachments:{
"foo.txt": {
content_type:"text/plain",
data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=",
length: "This is a base64 encoded text".length
}
}
};
Expand Down