Skip to content

Commit

Permalink
Add max_document_size checking for multipart PUT requests
Browse files Browse the repository at this point in the history
Previously multipart/related PUT requests didn't check maximum request sizes.

This commit checks content-length and compares that with the maximum.

This means keeping the current "semantics" of max_document_size which actually
means "max request size". But this makes the check more efficient and can
be done earlier in request processing time.

PR depends on apache/couchdb-couch#201 make sure to
merge that one first if accepted.

Jira: COUCHDB-3174
  • Loading branch information
nickva committed Oct 4, 2016
1 parent 297493f commit 5d7170c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/chttpd_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ db_doc_req(#httpd{method='PUT', user_ctx=Ctx}=Req, Db, DocId) ->
RespHeaders = [{"Location", Loc}],
case couch_util:to_list(couch_httpd:header_value(Req, "Content-Type")) of
("multipart/related;" ++ _) = ContentType ->
couch_httpd:check_max_request_length(Req),
couch_httpd_multipart:num_mp_writers(mem3:n(mem3:dbname(Db#db.name), DocId)),
{ok, Doc0, WaitFun, Parser} = couch_doc:doc_from_multi_part_stream(ContentType,
fun() -> receive_request_data(Req) end),
Expand Down

0 comments on commit 5d7170c

Please sign in to comment.