You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2011/05/26 01:03:28 UTC

svn commit: r1127715 - in /couchdb/trunk/src/couchdb: couch_db.erl couch_httpd_db.erl

Author: rnewson
Date: Wed May 25 23:03:28 2011
New Revision: 1127715

URL: http://svn.apache.org/viewvc?rev=1127715&view=rev
Log:
don't read more of an attachment than Content-Length states. (patch by Paul Davis, dictated not read).

Modified:
    couchdb/trunk/src/couchdb/couch_db.erl
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1127715&r1=1127714&r2=1127715&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Wed May 25 23:03:28 2011
@@ -998,7 +998,7 @@ with_stream(Fd, #att{md5=InMd5,type=Type
 write_streamed_attachment(_Stream, _F, 0) ->
     ok;
 write_streamed_attachment(Stream, F, LenLeft) when LenLeft > 0 ->
-    Bin = F(),
+    Bin = F(lists:min([LenLeft, 16#2000])),
     ok = couch_stream:write(Stream, Bin),
     write_streamed_attachment(Stream, F, LenLeft - size(Bin)).
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=1127715&r1=1127714&r2=1127715&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Wed May 25 23:03:28 2011
@@ -1071,7 +1071,7 @@ db_attachment_req(#httpd{method=Method,m
                         end,
                         
                         
-                        fun() -> couch_httpd:recv(Req, 0) end
+                        fun(Size) -> couch_httpd:recv(Req, Size) end
                     end,
                 att_len = case couch_httpd:header_value(Req,"Content-Length") of
                     undefined ->