anchor.diff:              Pid ! {self(), stop_ok},
               RedirectUrl = mochiweb_headers:get_value("Location", 
                   mochiweb_headers:make(StreamHeaders)),
  -            make_attachment_stub_receiver(RedirectUrl, Headers, Name, Type, Length, 
  -                Retries - 1);
  +            catch ibrowse:stop_worker_process(Conn),
  +            make_attachment_stub_receiver(RedirectUrl, Headers, Name, Type,
  +                Length, Retries - 1, Pause);
           ResponseCode >= 400, ResponseCode < 500 -> 
               % an error... log and fail
               ?LOG_ERROR("streaming attachment failed with code ~p: ~s", 
  
positive.code:         ResponseCode >= 300, ResponseCode < 400 ->
              RedirectUrl = mochiweb_headers:get_value("Location", 
                  mochiweb_headers:make(ResponseHeaders)),
              do_http_request(RedirectUrl, Action, Headers, JsonBody, Retries-1);
          ResponseCode >= 400, ResponseCode < 500 -> 
              ?JSON_DECODE(ResponseBody);        
          ResponseCode == 500 ->
              ?LOG_INFO("retrying couch_rep HTTP ~p request due to 500 error: ~s",
                  [Action, Url]),
              do_http_request(Url, Action, Headers, JsonBody, Retries - 1)
          end;
      {error, Reason} ->
          ?LOG_INFO("retrying couch_rep HTTP ~p request due to {error, ~p}: ~s", 
              [Action, Reason, Url]),
          do_http_request(Url, Action, Headers, JsonBody, Retries - 1)
      end.
  
  ensure_full_commit(#http_db{uri=DbUrl, headers=Headers}) ->
  
negative.code:     {Name, {Type, {RcvFun, Length}}}.
  
  make_attachment_stub_receiver(Url, Headers, Name, Type, Length) ->
      make_attachment_stub_receiver(Url, Headers, Name, Type, Length, 10, 1000).
  
  make_attachment_stub_receiver(Url, _Headers, _Name, _Type, _Length, 0, _Pause) ->
      ?LOG_ERROR("streaming attachment request failed after 10 retries: ~s", 
          [Url]),
      exit({attachment_request_failed, ?l2b(["failed to replicate ", Url])});
      
  make_attachment_stub_receiver(Url, Headers, Name, Type, Length, Retries, Pause) ->
      %% start the process that receives attachment data from ibrowse
      #url{host=Host, port=Port} = ibrowse_lib:parse_url(Url),
      {ok, Conn} = ibrowse:spawn_link_worker_process(Host, Port),
  