anchor.diff:     catch _:Reason ->
         ?NOTICE("knet [http]: egress failure ~p ~p", [Reason, erlang:get_stacktrace()]),
         % pipe:a(Pipe, {http, self(), eof}),
  -      {stop, normal, State}
  +      % {stop, normal, State}
  +      {next_state, 'IDLE', stream_reset(Pipe, State)}
      end.
   
   %%%------------------------------------------------------------------
  
positive.code:       end
     catch _:Reason ->
        ?NOTICE("knet [http]: ingress failure ~p ~p", [Reason, erlang:get_stacktrace()]),
        pipe:b(Pipe, {http, self(), eof}),
        {stop, normal, State0}
     end;
  
  %%
  
negative.code: up_link_upgrade(Upgrade, _, _) ->
     throw({not_implemented, Upgrade}).
  
  %%
  %%
  stream_reset(_Pipe, #fsm{queue = {}} = State) ->
     state_new(State);
  
  stream_reset(Pipe,  #fsm{socket = #socket{in = Stream}, queue = Queue} = State) ->
     case htstream:state(Stream) of
        payload ->
           send_eof_to_side(Pipe, q:head(Queue)),
           send_503_to_side(Pipe, q:tail(Queue));
        _       ->
           send_503_to_side(Pipe, Queue)
     end,
     state_new(State).
  
  send_eof_to_side(Pipe, _) ->
     pipe:b(Pipe, {http, self(), eof}).
  
  send_503_to_side(Pipe, Queue) ->
     lists:map(
        fun(_) -> 
           pipe:b(Pipe, {http, self(), {503, <<"Service Unavailable">>, []}}),
           pipe:b(Pipe, {http, self(), eof})
        end,
        q:list(Queue)
     ).
  
  state_new(#fsm{socket = #socket{so = Opts} = Socket}) ->
     #fsm{
        socket  = Socket
       ,queue   = q:new()
       ,trace   = opts:val(trace, undefined, Opts)
       ,so      = Opts
     }.
  
  %%%------------------------------------------------------------------
  %%%
  %%% private
  %%%
  %%%------------------------------------------------------------------
  
  %%
  %%
  -spec http_set_state(htstream:http(), #socket{}, #http{}) -> #http{}.
  
  http_set_state(Stream, Socket, #http{state = State} = Http) ->
     Http#http{
        is    = htstream:state(Stream),
        http  = htstream:http(Stream),
        state = State#fsm{socket = Socket}
     }.
  
  
  %%
  %% annotate http request with aux data 
  