couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1139894 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Date Sun, 26 Jun 2011 18:14:28 GMT
Author: fdmanana
Date: Sun Jun 26 18:14:28 2011
New Revision: 1139894

URL: http://svn.apache.org/viewvc?rev=1139894&view=rev
Log:
Don't steal data from subsequent requests in the pipeline

Modified:
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1139894&r1=1139893&r2=1139894&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Sun Jun 26 18:14:28 2011
@@ -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)).



Mime
View raw message