Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't steal data from subsequent requests in the pipeline

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1139894 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit cc2379ebbd45d842204642ac8a6a5a16669ffa4e 1 parent 0652aca
@fdmanana fdmanana authored
Showing with 14 additions and 6 deletions.
  1. +14 −6 src/couchdb/couch_httpd.erl
View
20 src/couchdb/couch_httpd.erl
@@ -476,16 +476,24 @@ body_length(Req) ->
Unknown -> {unknown_transfer_encoding, Unknown}
end.
-body(#httpd{mochi_req=MochiReq, req_body=ReqBody}) ->
- case ReqBody of
+body(#httpd{mochi_req=MochiReq, req_body=undefined} = Req) ->
+ case body_length(Req) of
undefined ->
- % Maximum size of document PUT request body (4GB)
MaxSize = list_to_integer(
couch_config:get("couchdb", "max_document_size", "4294967296")),
MochiReq:recv_body(MaxSize);
- _Else ->
- ReqBody
- end.
+ chunked ->
+ ChunkFun = fun({0, _Footers}, Acc) ->
+ lists:reverse(Acc);
+ ({_Len, Chunk}, Acc) ->
+ [Chunk | Acc]
+ end,
+ recv_chunked(Req, 8192, ChunkFun, []);
+ Len ->
+ MochiReq:recv_body(Len)
+ end;
+body(#httpd{req_body=ReqBody}) ->
+ ReqBody.
json_body(Httpd) ->
?JSON_DECODE(body(Httpd)).
Please sign in to comment.
Something went wrong with that request. Please try again.