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:     Opts = [{stream_to, Pid}, {response_format, binary}],
      ReqId = 
      case ibrowse:send_req_direct(Conn, Url, Headers, get, [], Opts, infinity) of
          {ibrowse_req_id, X} -> X;
          {error, Reason} ->
              exit({attachment_request_failed,
                  ?l2b(["ibrowse error on ", Url, " : ", atom_to_list(Reason)])})
      end,
      
      %% tell our receiver about the ReqId it needs to look for
      Pid ! {self(), {set_req_id, ReqId}},
      receive {Pid, {ok, ReqId}} -> ok end,
      
      %% wait for headers to ensure that we have a 200 status code
      %% this is where we follow redirects etc
      Pid ! {self(), gimme_status}, 
      receive
      {'EXIT', Pid, attachment_request_failed} ->
          make_attachment_stub_receiver(Url, Headers, Name, Type, Length, Retries-1);
      {Pid, {status, StreamStatus, StreamHeaders}} -> 
          ?LOG_DEBUG("streaming attachment Status ~p Headers ~p",
              [StreamStatus, StreamHeaders]),
  
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),
  