Skip to content

Commit

Permalink
eptic: use re instead of regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
roques committed Dec 14, 2010
1 parent 890facf commit d52e9f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/eptic-1.4.1/src/e_multipart_inets.erl
Expand Up @@ -30,7 +30,7 @@

get_multipart(Body, Boundary) ->
Regexp = Boundary ++ "((\r\n)|(\-\-\r\n))",
{ok, Split} = regexp:split(Body, Regexp),
{ok, Split} = re:split(Body, Regexp),
retrive_data(Split).

terminate() ->
Expand All @@ -48,11 +48,11 @@ retrive_data([]) ->
retrive_data([[] | Rest]) ->
retrive_data(Rest);
retrive_data(["Content-Disposition: form-data; " ++ Element | Rest]) ->
{match, HeaderStart, HeaderLen} = regexp:first_match(Element, ".*\r\n"),
{match, HeaderStart, HeaderLen} = re:first_match(Element, ".*\r\n"),
HeaderString = string:substr(Element, HeaderStart, HeaderLen-2),
{ok, Fields} = regexp:split(HeaderString, "; "),
{ok, Fields} = re:split(HeaderString, "; "),
Header = lists:foldl(fun(E, Acc) ->
{ok, [Key, Value]} = regexp:split(E, "="),
{ok, [Key, Value]} = re:split(E, "="),
[{list_to_atom(Key), Value} | Acc]
end, [], Fields),
HeaderLength = HeaderStart+HeaderLen+2,
Expand All @@ -72,7 +72,7 @@ retrive_data(["Content-Disposition: form-data; " ++ Element | Rest]) ->
[{Name, []} | retrive_data(Rest)];
{value, {filename, SFilename}} ->
Filename0 = string:strip(SFilename, both, 34),
Filename = case regexp:first_match(Content, "\r\n\r\n") of
Filename = case re:first_match(Content, "\r\n\r\n") of
{match, ContentS, _} ->
save_file(Filename0, string:substr(Content, ContentS+4));
nomatch ->
Expand Down

0 comments on commit d52e9f8

Please sign in to comment.