anchor.diff:  
   -export([replicate/2]).
   
  +-define(BUFFER_NDOCS, 1000).
  +-define(BUFFER_NATTACHMENTS, 50).
  +-define(BUFFER_MEMORY, 10000000). %% bytes
  +
   -include("couch_db.hrl").
  +-include("../ibrowse/ibrowse.hrl").
   
   %% @spec replicate(Source::binary(), Target::binary()) -> 
   %%      {ok, Stats} | {error, Reason}
  
positive.code:     
  make_attachment_stub_receiver(Url, Headers, Name, Type, Length, Retries) ->
      %% start the process that receives attachment data from ibrowse
      Pid = spawn_link(fun() -> attachment_loop(nil) end),
      
      %% make the async request
      Options = [{stream_to, Pid}, {response_format, binary}],
      ReqId = case ibrowse:send_req(Url, Headers, get, [], Options, infinity) of
          {ibrowse_req_id, X} -> X;
          {error, _Reason} -> exit(attachment_request_failed)
      end,
  
negative.code:     ets:update_counter(State#state.stats, total_revs, RevsCount),
      case State#state.listeners of
      [] ->
          % still waiting for the first listener to send a request
          {noreply, State#state{current_seq=LastSeq,done=true}};
      _ ->
          {stop, normal, ok, State#state{current_seq=LastSeq}}
  