anchor.diff:  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
   %% @private
  --spec init([term()]) -> term().
  -init([Host, Port, Type]) ->
  +-spec init([term()]) -> {ok, at_rest, map()} | {stop, gun_open_timeout} | {stop, gun_open_failed}.
  +init([Host, Port, Type, Opts]) ->
       GunType = case Type of
                     http -> tcp;
                     https -> ssl
                 end,
  -    Opts = #{transport      => GunType,
  -             retry          => 1,
  -             retry_timeout  => 1
  -            },
  -    {ok, Pid} = gun:open(Host, Port, Opts),
  -    State = clean_state(),
  -    {ok, at_rest, State#{pid => Pid}}.
  +    TransportOpts = maps:get(transport_opts, Opts, []),
  +    GunOpts = #{transport      => GunType,
  +                retry          => 1,
  +                retry_timeout  => 1,
  +                transport_opts => TransportOpts
  +               },
  +    Timeout = maps:get(timeout, Opts, 5000),
  +    {ok, Pid} = gun:open(Host, Port, GunOpts),
  +    case gun:await_up(Pid, Timeout) of
  +      {ok, _} ->
  +        State = clean_state(),
  +        {ok, at_rest, State#{pid => Pid}};
  +      %The only apparent timeout for gun:open is the connection timeout of the
  +      %underlying transport. So, a timeout message here comes from gun:await_up.
  +      {error, timeout} ->
  +        {stop, gun_open_timeout};
  +      %gun currently terminates with reason normal if gun:open fails to open
  +      %the requested connection. This bubbles up through gun:await_up.
  +      {error, normal} ->
  +        {stop, gun_open_failed}
  +    end.
   
   %% @private
   -spec handle_event(term(), atom(), term()) -> term().
  
positive.code:     application:stop(shotgun).
  
  %% @private
  -spec start_link(string(), integer(), connection_type()) ->
      {ok, pid()} | ignore | {error, term()}.
  start_link(Host, Port, Type) ->
      gen_fsm:start_link(shotgun, [Host, Port, Type], []).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% API
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  %% @equiv get(Host, Port, http)
  -spec open(Host :: string(), Port :: integer()) -> {ok, pid()}.
  open(Host, Port) ->
      open(Host, Port, http).
  
  %% @doc Opens a connection of the type provided with the host in port specified.
  -spec open(Host :: string(), Port :: integer(), Type :: connection_type()) ->
      {ok, pid()}.
  open(Host, Port, Type) ->
      supervisor:start_child(shotgun_sup, [Host, Port, Type]).
  
  
  %% @doc Closes the connection with the host.
  -spec close(pid()) -> ok.
  
negative.code: -export([
           start/0,
           stop/0,
           start_link/4,
           open/2,
           open/3,
           open/4,
           close/1,
           %% get
           get/2,
  