anchor.diff:  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_result([Chnk | Acc], S).
   
   %%
   encode_version({Major, Minor}) ->
  
positive.code: encode_header({_, Headers}, Acc, S)
   when is_list(Headers) ->
     Head = [<<(encode_header_value(X))/binary, "\r\n">> || X <- Headers],
     Http = lists:reverse([iolist_to_binary([Head, $\r, $\n]) | Acc]),
     {Http, encode_check_payload(S#http{headers=Headers})};
  encode_header({_, _Url, Headers}, Acc, S)
   when is_list(Headers) ->
     Head = [<<(encode_header_value(X))/binary, "\r\n">> || X <- Headers],
     Http = lists:reverse([iolist_to_binary([Head, $\r, $\n]) | Acc]),
     {Http, encode_check_payload(S#http{headers=Headers})};
  encode_header({_, Headers, Payload}, Acc, S)
   when is_list(Headers) ->
     Head = [<<(encode_header_value(X))/binary, "\r\n">> || X <- Headers],
  
negative.code: %% encode entity payload
  encode(Pckt, Acc, #http{is=entity, length=Len}=S)
   when is_integer(Len), size(Pckt) < Len ->
     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,
     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
     encode_result([Pckt  | Acc], S);
  
  
  %% encode chunked payload 
  