Skip to content

Commit

Permalink
v1.51: remove unused functions from cb_util
Browse files Browse the repository at this point in the history
  • Loading branch information
James Aimonetti committed Apr 4, 2012
1 parent 17f2597 commit bccc675
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
26 changes: 0 additions & 26 deletions whistle_apps/apps/crossbar/src/crossbar_util.erl
Expand Up @@ -532,32 +532,6 @@ get_path1(RawPath, Relative) ->
end, PathTokensRev, UrlTokens)
), <<"/">>).

parse_qs(QS) ->
parse_qs(QS, []).

parse_qs(QS, Acc) ->
{K, Rest} = parse_qs_key(QS),
{V, Rest1} = parse_qs_key(Rest),
parse_qs(Rest1, [{K, V}|Acc]).

parse_qs_key(<<" ", R/binary>>) ->
parse_qs_key(R);
parse_qs_key(V) ->
parse_qs_key(V, <<>>).

parse_qs_key(<<>>, Acc) ->
{Acc, <<>>};
parse_qs_key(<<"=", R/binary>>, Acc) ->
{Acc, R};
parse_qs_key(<<";", _/binary>> = R, Acc) ->
{Acc, R};
parse_qs_key(<<"&", _/binary>> = R, Acc) ->
{Acc, R};
parse_qs_key(<<C:1/binary, R/binary>>, Acc) ->
parse_qs_key(R, <<Acc/binary, C/binary>>).



-include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).

Expand Down
13 changes: 1 addition & 12 deletions whistle_apps/apps/crossbar/src/v1_util.erl
Expand Up @@ -161,7 +161,6 @@ extract_multipart(#cb_context{req_files=Files}=Context, #http_req{}=Req0) ->
case extract_multipart_content(MPData, wh_json:new()) of
{eof, Req1} -> {Context, Req1};
{end_of_part, JObj, Req1} ->

extract_multipart(Context#cb_context{req_files=[JObj|Files]}, Req1)
end.

Expand All @@ -172,7 +171,7 @@ extract_multipart_content({end_of_part, Req}, JObj) -> {end_of_part, JObj, Req};
extract_multipart_content({{headers, Headers}, Req}, JObj) ->
lager:debug("setting multipart headers: ~p", [Headers]),
MPData = cowboy_http_req:multipart_data(Req),
extract_multipart_content(MPData, wh_json:set_value(<<"headers">>, extract_headers(Headers), JObj));
extract_multipart_content(MPData, wh_json:set_value(<<"headers">>, Headers, JObj));
extract_multipart_content({{body, Datum}, Req}, JObj) ->
extract_multipart_content({{data, Datum}, Req}, JObj);
extract_multipart_content({{data, Datum}, Req}, JObj) ->
Expand All @@ -181,16 +180,6 @@ extract_multipart_content({{data, Datum}, Req}, JObj) ->
,wh_json:set_value(<<"data">>, <<Data/binary, Datum/binary>>, JObj)
).

extract_headers([_|_]=Headers) ->
case props:get_value(<<"Content-Disposition">>, Headers) of
<<"form-data; ", Key/binary>> ->
lager:debug("creating headers from ~s", [Key]),
mochiweb_util:parse_qs(Key);
_CD ->
lager:debug("unhandled content disposition: ~p", [_CD]),
Headers
end.

-spec extract_file/3 :: (#cb_context{}, ne_binary(), #http_req{}) -> {#cb_context{}, #http_req{}}.
extract_file(Context, ContentType, Req0) ->
case cowboy_http_req:body(Req0) of
Expand Down

0 comments on commit bccc675

Please sign in to comment.