Skip to content

Commit

Permalink
Merge pull request #2 from seanmcevoy/ee-test-modifications
Browse files Browse the repository at this point in the history
tweaks due to issues in EE POC
  • Loading branch information
bsparrow435 authored Oct 5, 2016
2 parents 940123f + 9b76ea4 commit e0633f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/webmachine_multipart.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ find_boundary(ReqData) ->

% @doc Turn a multipart form into component parts.
% @spec get_all_parts(incoming_req_body(), boundary()) -> [fpart()]
get_all_parts(Body, Boundary) when is_list(Body), is_list(Boundary) ->
get_all_parts(list_to_binary(Body), Boundary);
get_all_parts(Body, Boundary) when is_binary(Body), is_list(Boundary) ->
StreamStruct = send_streamed_body(Body,1024),
getparts1(stream_parts(StreamStruct, Boundary), []).
Expand All @@ -71,6 +73,8 @@ stream_form({Hunk, Next}, Boundary, []) ->
stream_form(get_more_data(Next), Boundary, re:split(Hunk, Boundary,[]));
stream_form({Hunk, Next}, Boundary, [<<>>|DQ]) ->
stream_form({Hunk, Next}, Boundary, DQ);
stream_form({Hunk, Next}, Boundary, [<<"\r\n">>|DQ]) ->
stream_form({Hunk, Next}, Boundary, DQ);
stream_form({Hunk, Next}, Boundary, [H|[T1|T2]]) ->
{make_part(H), fun() ->
stream_form({Hunk, Next}, Boundary, [T1|T2]) end};
Expand All @@ -94,7 +98,7 @@ stream_parts([H|T]) -> {make_part(H), fun() -> stream_parts(T) end}.

get_more_data(done) -> {<<"--\n">>, really_done};
get_more_data(Fun) -> Fun().

make_part(PartData) ->
%% Remove the trailing \r\n
[HeadData, BodyWithCRLF] = re:split(PartData, "\\r\\n\\r\\n", [{parts,2}]),
Expand Down

0 comments on commit e0633f5

Please sign in to comment.