diff options
author | Damien F. Katz <damien@apache.org> | 2010-06-10 23:35:01 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2010-06-10 23:35:01 +0000 |
commit | 9a0de9a3f3828e5269f39f688c4e50db41527e8c (patch) | |
tree | 52698713c82362d48d82acfef7419a199e603063 /src | |
parent | 5aae08bf66411e4e81b21a3c137627733efa6b26 (diff) |
Code mods to support streaming attachment replication.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@953499 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_doc.erl | 4 | ||||
-rw-r--r-- | src/couchdb/couch_httpd.erl | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl index d6eeb9fa..6c8f522d 100644 --- a/src/couchdb/couch_doc.erl +++ b/src/couchdb/couch_doc.erl @@ -308,7 +308,9 @@ att_foldl(#att{data=DataFun,att_len=Len}, Fun, Acc) when is_function(DataFun) -> fold_streamed_data(DataFun, Len, Fun, Acc). att_foldl_decode(#att{data={Fd,Sp},md5=Md5,encoding=Enc}, Fun, Acc) -> - couch_stream:foldl_decode(Fd, Sp, Md5, Enc, Fun, Acc). + couch_stream:foldl_decode(Fd, Sp, Md5, Enc, Fun, Acc); +att_foldl_decode(#att{data=Fun,att_len=Len, encoding=identity}, Fun, Acc) -> + fold_streamed_data(Fun, Len, Fun, Acc). att_to_bin(#att{data=Bin}) when is_binary(Bin) -> Bin; diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index a8f0bb58..d009b0d6 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -799,6 +799,11 @@ read_until(#mp{data_fun=DataFun, buffer=Buffer}=Mp, Pattern, Callback) -> {Buffer2, DataFun2} = DataFun(), Buffer3 = iolist_to_binary(Buffer2), read_until(Mp#mp{data_fun=DataFun2,buffer=Buffer3}, Pattern, Callback2); + {partial, 0} -> + {NewData, DataFun2} = DataFun(), + read_until(Mp#mp{data_fun=DataFun2, + buffer= iolist_to_binary([Buffer,NewData])}, + Pattern, Callback); {partial, Skip} -> <<DataChunk:Skip/binary, Rest/binary>> = Buffer, Callback2 = Callback(DataChunk), @@ -806,6 +811,10 @@ read_until(#mp{data_fun=DataFun, buffer=Buffer}=Mp, Pattern, Callback) -> read_until(Mp#mp{data_fun=DataFun2, buffer= iolist_to_binary([Rest | NewData])}, Pattern, Callback2); + {exact, 0} -> + PatternLen = size(Pattern), + <<_:PatternLen/binary, Rest/binary>> = Buffer, + {Mp#mp{buffer= Rest}, Callback}; {exact, Skip} -> PatternLen = size(Pattern), <<DataChunk:Skip/binary, _:PatternLen/binary, Rest/binary>> = Buffer, |