anchor.diff:  %% encode entity payload
   encode(Pckt, Acc, #http{is=entity, length=Len}=S)
    when is_integer(Len), size(Pckt) < Len ->
  -   {lists:reverse([Pckt  | Acc]), S#http{length=Len - size(Pckt)}};
  +   encode_result([Pckt  | Acc], S#http{length = Len - byte_size(Pckt)});
   
   encode(Pckt, Acc, #http{is=entity, length=Len}=S)
    when is_integer(Len) ->
      %% TODO: preserve Rest to sndbuf
      <<Chunk:Len/binary, _Rest/binary>> = Pckt,
  -   {lists:reverse([Chunk | Acc]), S#http{is=eof, length=0}};
  +   encode_result([Chunk | Acc], S#http{is = eof, length = 0});
   
   encode(Pckt, Acc, #http{is=entity, length=inf}=S) ->
      % message length is determined by closed connection
  -   {lists:reverse([Pckt  | Acc]), S};
  +   encode_result([Pckt  | Acc], S);
   
   
   %% encode chunked payload 
  
positive.code: encode_chunk(Chunk, Acc, S) ->
     Size = integer_to_list(size(Chunk), 16),
     Chnk = iolist_to_binary([<<(list_to_binary(Size))/binary, $\r, $\n>>, Chunk, <<$\r, $\n>>]),
     Http = lists:reverse([Chnk | Acc]),
     {Http, S}.
  
  %%
  encode_version({Major, Minor}) ->
  
negative.code: 
  encode(Msg) ->
     encode(Msg, new()).
  encode(Msg, #http{}=S) ->
     encode(Msg, [], S).
  
  
  
  