anchor.diff:              {next_state, 'SERVER', State#fsm{recv=Http}}
         end
      catch _:Reason ->
  -      % io:format("--> ~p ~p~n", [Reason, erlang:get_stacktrace()]),
  +      ?NOTICE("knet [http]: failure ~p ~p", [Reason, erlang:get_stacktrace()]),
         pipe:a(Pipe, erlang:element(1, htstream:encode({Reason, make_head()}))),
         {stop, normal, State#fsm{recv=htstream:new()}}
      end;
  
positive.code: 'CLIENT'(shutdown, _Pipe, S) ->
     {stop, normal, S};
  
  'CLIENT'({tcp, _, established}, _, S) ->
     {next_state, 'CLIENT', S#fsm{schema=http,  ts=os:timestamp()}};
  
  'CLIENT'({ssl, _, established}, _, S) ->
     {next_state, 'CLIENT', S#fsm{schema=https, ts=os:timestamp()}};
  
  'CLIENT'({Prot, _, {terminated, _}}, Pipe, S)
   when Prot =:= tcp orelse Prot =:= ssl ->
     case htstream:state(S#fsm.recv) of
        payload -> 
           % time to meaningful response
           _ = knet:trace(S#fsm.trace, {http, ttmr, tempus:diff(S#fsm.ts)}),         
           _ = pipe:b(Pipe, {http, S#fsm.url, eof});
        _       -> 
           ok
     end,
     {stop, normal, S};
  
  %%
  %% remote acceptor response
  'CLIENT'({Prot, Peer, Pckt}, Pipe, S)
   when is_binary(Pckt), Prot =:= tcp orelse Prot =:= ssl ->
     try
        {next_state, 'CLIENT', http_inbound(Pckt, Peer, Pipe, S)}
     catch _:Reason ->
        %io:format("----> ~p ~p~n", [Reason, erlang:get_stacktrace()]),
        {stop, Reason, S}
     end;
  
  %%
  %% local client request
  'CLIENT'({Mthd, {uri, _, _}=Uri, Heads}, Pipe, S) ->
     'CLIENT'({Mthd, uri:path(Uri), Heads}, Pipe, S#fsm{url=Uri, ts=os:timestamp()});
  
  'CLIENT'({Mthd, {uri, _, _}=Uri, Heads, Msg}, Pipe, S) ->
     'CLIENT'({Mthd, uri:path(Uri), Heads, Msg}, Pipe, S#fsm{url=Uri, ts=os:timestamp()});
  
  'CLIENT'(Msg, Pipe, S) ->
     {next_state, 'CLIENT', http_outbound(Msg, Pipe, S)}.
     
  %%%------------------------------------------------------------------
  %%%
  
negative.code: send_to_acceptor([], _Pipe, _State) ->
     ok;
  
  send_to_acceptor({Code, Status, Head}, Pipe, State)
   when is_integer(Code) ->
     pipe:b(Pipe, {http, self(), {Code, Status, Head, make_env(State#fsm.url, Head, State)}});
  
  send_to_acceptor({Mthd, Url, Head}, Pipe, State) ->
     Uri = request_url(State#fsm.schema, Url, Head),
     pipe:b(Pipe, {http, self(), {Mthd, Uri, Head, make_env(Uri, Head, State)}});
  
  send_to_acceptor(Chunk, Pipe, _State) ->
     pipe:b(Pipe, {http, self(), erlang:iolist_to_binary(Chunk)}).
  
  %%
  