You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2009/07/03 03:08:44 UTC

svn commit: r790773 - /couchdb/trunk/src/couchdb/couch_db.erl

Author: kocolosk
Date: Fri Jul  3 01:08:43 2009
New Revision: 790773

URL: http://svn.apache.org/viewvc?rev=790773&view=rev
Log:
update check_bin_length since chunked response bug is fixed

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

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=790773&r1=790772&r2=790773&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Fri Jul  3 01:08:43 2009
@@ -617,14 +617,15 @@
     ok = couch_stream:write(Stream, TruncatedBin),
     write_streamed_attachment(Stream, F, LenLeft - size(TruncatedBin)).
 
-%% on rare occasions ibrowse seems to process a chunked response incorrectly
-%% and include an extra "\r" in the last chunk.  This code ensures that we 
-%% truncate the downloaed attachment at the length specified in the metadata.
+%% There was a bug in ibrowse 1.4.1 that would cause it to append a CR to a
+%% chunked response when the CR and LF terminating the last data chunk were
+%% split across packets.  The bug was fixed in version 1.5.0, but we still
+%% check for it just in case.
 check_bin_length(LenLeft, Bin) when size(Bin) > LenLeft ->
-    <<ValidData:LenLeft/binary, Crap/binary>> = Bin,
+    <<_ValidData:LenLeft/binary, Crap/binary>> = Bin,
     ?LOG_ERROR("write_streamed_attachment has written too much expected: ~p" ++
         " got: ~p tail: ~p", [LenLeft, size(Bin), Crap]),
-    ValidData;
+    exit(replicated_attachment_too_large);
 check_bin_length(_, Bin) -> Bin.
 
 enum_docs_since_reduce_to_count(Reds) ->