anchor.diff:  -module(psycho_multipart).
   
  --export([new/3, data/2, form_data/1]).
  +-export([new/1, new/2, data/2, form_data/1]).
   
   -record(mp, {boundary_delim, parts, headers, acc}).
   
  -new(Boundary, _Callback, _Data) when is_binary(Boundary) ->
  +new(Boundary) ->
  +    new(Boundary, {undefined, undefined}).
  +
  +new(Boundary, {_Callback, _Data}) when is_binary(Boundary) ->
       #mp{
          boundary_delim=boundary_delim(Boundary),
          parts=[],
  
positive.code:     MP#mp{headers=Headers}.
  
  parse_headers(<<"\r\n", Raw/binary>>) ->
      [parse_header(Part) || Part <- split_headers(Raw)].
  
  split_headers(Raw) ->
      binary:split(Raw, <<"\r\n">>, [global]).
  
  parse_header(Raw) ->
      case binary:split(Raw, <<":">>) of
          [Name, RawVal] -> {Name, header_val(RawVal)};
          [Name] -> {Name, <<>>}
      end.
  
  header_val(<<" ", Val/binary>>) -> Val;
  header_val(Val) -> Val.
  
  add_cur(#mp{headers=Headers, acc=Acc, parts=Parts}=MP) ->
      Part = {Headers, finalize_body(Acc)},
      MP#mp{parts=[Part|Parts], headers=pending, acc=[]}.
  
  start_body(Data, MP) -> MP#mp{acc=[Data]}.
  
  finalize_body([]) -> <<>>;
  finalize_body([Last|Rest]) ->
  
negative.code: new_part(Data, MP) ->
      try_headers(Data, MP).
  
  form_data(#mp{parts=Parts}) ->
      lists:reverse(Parts).
  