anchor.diff:      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)])})
  +    {ibrowse_req_id, X} -> 
  +        X;
  +    {error, Reason} ->
  +        ?LOG_INFO("retrying couch_rep attachment request in ~p " ++
  +            "seconds due to {error, ~p}: ~s", [Pause/1000, Reason, Url]),
  +        catch ibrowse:stop_worker_process(Conn),
  +        timer:sleep(Pause),
  +        make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
  +            Retries-1, 2*Pause)
       end,
       
       %% tell our receiver about the ReqId it needs to look for
       Pid ! {self(), {set_req_id, ReqId}},
  -    receive {Pid, {ok, ReqId}} -> ok end,
  +    receive 
  +    {Pid, {ok, ReqId}} -> 
  +        ok;
  +    {'EXIT', Pid, _Reason} ->
  +        catch ibrowse:stop_worker_process(Conn),
  +        timer:sleep(Pause),
  +        make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
  +            Retries-1, 2*Pause)
  +    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);
  +        catch ibrowse:stop_worker_process(Conn),
  +        make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
  +            Retries-1, Pause);
       {Pid, {status, StreamStatus, StreamHeaders}} -> 
           ?LOG_DEBUG("streaming attachment Status ~p Headers ~p",
               [StreamStatus, StreamHeaders]),
  
positive.code:             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);
          ResponseCode >= 400, ResponseCode < 500 -> 
              % an error... log and fail
              ?LOG_ERROR("streaming attachment failed with code ~p: ~s", 
  
negative.code:     do_http_request(Url, Action, Headers, []).
  
  do_http_request(Url, Action, Headers, JsonBody) ->
      do_http_request(Url, Action, Headers, JsonBody, 10, 1000).
  
  do_http_request(Url, Action, Headers, Body, Retries, Pause) when is_binary(Url) ->
      do_http_request(?b2l(Url), Action, Headers, Body, Retries, Pause);
  do_http_request(Url, Action, _Headers, _JsonBody, 0, _Pause) ->
      ?LOG_ERROR("couch_rep HTTP ~p request failed after 10 retries: ~s", 
          [Action, Url]),
      exit({http_request_failed, ?l2b(["failed to replicate ", Url])});
  do_http_request(Url, Action, Headers, JsonBody, Retries, Pause) ->
      ?LOG_DEBUG("couch_rep HTTP ~p request: ~s", [Action, Url]),
      Body =
      case JsonBody of
  