diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2011-06-26 18:19:03 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2011-06-26 18:19:03 +0000 |
commit | 7e906e64a56dbb1dceb1ce95023a2a1af5af8ec9 (patch) | |
tree | 6fcda00a5b53d0b6fdc10109b8669adb7da6c758 | |
parent | 71eb2040ff0da968868a3d97a5a1dee4eb4ea651 (diff) |
Merged revision 1139894 from trunk
Don't steal data from subsequent requests in the pipeline
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1139897 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/couchdb/couch_httpd.erl | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 7c7781f6..e472d094 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -469,16 +469,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)). |