Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge branch 'couchdb-3174'
  • Loading branch information
nickva committed Oct 6, 2016
2 parents fc082b4 + 7dec013 commit bfed196d4cade50be6864db71611f0b909cc919b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
@@ -33,6 +33,8 @@
-export([http_1_0_keep_alive/2]).
-export([validate_host/1]).
-export([validate_bind_address/1]).
-export([check_max_request_length/1]).


-define(HANDLER_NAME_IN_MODULE_POS, 6).

@@ -446,6 +448,18 @@ validate_ctype(Req, Ctype) ->
end
end.


check_max_request_length(Req) ->
Len = list_to_integer(header_value(Req, "Content-Length", "0")),
MaxLen = config:get_integer("couchdb", "max_document_size", 4294967296),
case Len > MaxLen of
true ->
exit({body_too_large, Len});
false ->
ok
end.


% Utilities

partition(Path) ->
@@ -583,6 +583,7 @@ db_doc_req(#httpd{method='PUT'}=Req, Db, DocId) ->

case couch_util:to_list(couch_httpd:header_value(Req, "Content-Type")) of
("multipart/related;" ++ _) = ContentType ->
couch_chttpd:check_max_request_length(Req),
{ok, Doc0, WaitFun, Parser} = couch_doc:doc_from_multi_part_stream(
ContentType, fun() -> receive_request_data(Req) end),
Doc = couch_doc_from_req(Req, DocId, Doc0),

0 comments on commit bfed196

Please sign in to comment.