anchor.diff:  -module(mochiweb_multipart).
   -author('bob@mochimedia.com').
   
  --export([parse_form/2]).
  +-export([parse_form/1, parse_form/2]).
   -export([parse_multipart_request/2]).
   -export([test/0]).
   
  
positive.code:     ok = with_socket_server(ServerFun, ClientFun),
      ok.
  
  handler_test(Filename, ContentType) ->
      fun (Next) ->
              handler_test_read(Next, {Filename, ContentType}, [])
      end.
  
  handler_test_read(eof, {Filename, ContentType}, Acc) ->
      Value = iolist_to_binary(lists:reverse(Acc)),
      {Filename, ContentType, Value};
  handler_test_read(Data, H, Acc) ->
      Acc1 = [Data | Acc],
      fun (Next) -> handler_test_read(Next, H, Acc1) end.
  
  
  test_parse_form() ->
      ContentType = "multipart/form-data; boundary=AaB03x",
      "AaB03x" = get_boundary(ContentType),
  
negative.code: parse_form_file({body, Data}, {Name, Handler}, FileHandler, State) ->
      H1 = Handler(Data),
      fun (Next) -> parse_form_file(Next, {Name, H1}, FileHandler, State) end.
  
  default_file_handler(Filename, ContentType) ->
      default_file_handler_1(Filename, ContentType, []).
  
  default_file_handler_1(Filename, ContentType, Acc) ->
      fun(eof) ->
              Value = iolist_to_binary(lists:reverse(Acc)),
              {Filename, ContentType, Value};
         (Next) ->
              default_file_handler_1(Filename, ContentType, [Next | Acc])
      end.
  
  parse_multipart_request(Req, Callback) ->
      %% TODO: Support chunked?
  