anchor.diff:              %% be the one to actually receive the ibrowse data.
               {ok, fun() -> 
                   Pid ! {self(), gimme_data}, 
  -                receive {Pid, Data} -> Data end
  +                receive 
  +                    {Pid, Data} -> 
  +                        Data;
  +                    {'EXIT', Pid, attachment_request_failed} ->
  +                        throw(attachment_write_failed)
  +                end
               end};
           ResponseCode >= 300, ResponseCode < 400 ->
               % follow the redirect
  
positive.code:     %% wait for headers to ensure that we have a 200 status code
      %% this is where we follow redirects etc
      Pid ! {self(), gimme_status}, 
      receive {Pid, {status, StreamStatus, StreamHeaders}} -> 
          ?LOG_DEBUG("streaming attachment Status ~p Headers ~p",
              [StreamStatus, StreamHeaders]),
          
  
negative.code:     case should_flush(lists:flatlength([Docs|Buffer])) of
          true ->
              Docs2 = lists:flatten([Docs|Buffer]),
              try update_docs(Target, Docs2, [], replicated_changes) of
              {ok, Errors} ->
                  dump_update_errors(Errors),
                  ets:update_counter(Stats, doc_write_failures, length(Errors)),
                  ets:update_counter(Stats, docs_written, length(Docs2) -
                          length(Errors)),
                  {ok, _, Ctxt} = do_checkpoint(Source, Target, Context, Seq, Stats),
                  {[], Ctxt}
              catch
              throw:attachment_write_failed ->
                  ?LOG_ERROR("attachment request failed during write to disk", []),
                  exit({internal_server_error, replication_link_failure})
              end;
          false ->
              {[Docs | Buffer], Context}
      end,
  