anchor.diff:      erlang:erase({ibrowse_pid, Url#url.host}),
       ok.
   
  +maybe_disconnect(Url) ->
  +    case erlang:get(disconnect_freq) of
  +        infinity -> ok;
  +        {ops, Count} -> should_disconnect_ops(Count,Url) andalso disconnect(Url);
  +        Seconds -> should_disconnect_secs(Seconds,Url) andalso disconnect(Url)
  +    end.
  +
  +should_disconnect_ops(Count, Url) ->
  +    Key = {ops_since_disconnect, Url#url.host},
  +    case erlang:get(Key) of
  +        undefined ->
  +            erlang:put(Key, 1),
  +            false;
  +        Count ->
  +            erlang:put(Key, 0),
  +            true;
  +        Incr ->
  +            erlang:put(Key, Incr + 1),
  +            false
  +    end.
  +
  +should_disconnect_secs(Seconds, Url) ->
  +    Key = {last_disconnect, Url#url.host},
  +    case erlang:get(Key) of
  +        undefined ->
  +            erlang:put(Key, erlang:now()),
  +            false;
  +        Time when is_tuple(Time) andalso size(Time) == 3 ->
  +            Diff = timer:now_diff(erlang:now(), Time),
  +            if
  +                Diff >= Seconds * 1000000 ->
  +                    erlang:put(Key, erlang:now()),
  +                    true;
  +                true -> false
  +            end
  +    end.
  +
  +clear_disconnect_freq(Url) ->
  +    case erlang:get(disconnect_freq) of
  +        infinity -> ok;
  +        {ops, Count} -> erlang:put({ops_since_disconnect, Url#url.host}, 0);
  +        Seconds -> erlang:put({last_disconnect, Url#url.host}, erlang:now())
  +    end.
   
   send_request(Url, Headers, Method, Body, Options) ->
       send_request(Url, Headers, Method, Body, Options, 3).
  
positive.code:                  base_urls,          % Tuple of #url -- one for each IP
                   base_urls_index,    % #url to use for next request
                   path_params }).     % Params to append on the path
  
  %% ====================================================================
  %% API
  
negative.code:     Pid = connect(Url),
      case catch(ibrowse_http_client:send_req(Pid, Url, Headers, Method, Body, Options, 5000)) of
          {ok, Status, RespHeaders, RespBody} ->
              maybe_disconnect(Url),
              {ok, Status, RespHeaders, RespBody};
  
          Error ->
              clear_disconnect_freq(Url),
              disconnect(Url),
              case should_retry(Error) of
                  true ->
  