diff --git a/deps/rabbitmq_web_dispatch/Makefile b/deps/rabbitmq_web_dispatch/Makefile index c77a14b24d..34548cfae4 100644 --- a/deps/rabbitmq_web_dispatch/Makefile +++ b/deps/rabbitmq_web_dispatch/Makefile @@ -3,7 +3,7 @@ APPNAME=rabbit_mochiweb DEPS= INTERNAL_DEPS=mochiweb RUNTIME_DEPS=mochiweb -TEST_APPS=crypto inets mochiweb rabbit_mochiweb rabbit_mochiweb_test +TEST_APPS=inets mochiweb rabbit_mochiweb rabbit_mochiweb_test TEST_COMMANDS=rabbit_mochiweb_test:test() include ../include.mk diff --git a/deps/rabbitmq_web_dispatch/deps/mochiweb/10-crypto.patch b/deps/rabbitmq_web_dispatch/deps/mochiweb/10-crypto.patch new file mode 100644 index 0000000000..48ecde7d69 --- /dev/null +++ b/deps/rabbitmq_web_dispatch/deps/mochiweb/10-crypto.patch @@ -0,0 +1,206 @@ +diff --git a/priv/skel/src/skel.app b/priv/skel/src/skel.app +index fc16aae..2b064dd 100644 +--- a/priv/skel/src/skel.app ++++ b/priv/skel/src/skel.app +@@ -11,4 +11,4 @@ + {registered, []}, + {mod, {skel_app, []}}, + {env, []}, +- {applications, [kernel, stdlib, crypto]}]}. ++ {applications, [kernel, stdlib]}]}. +diff --git a/priv/skel/src/skel.erl b/priv/skel/src/skel.erl +index 7ac4e2b..9776e02 100644 +--- a/priv/skel/src/skel.erl ++++ b/priv/skel/src/skel.erl +@@ -19,12 +19,10 @@ ensure_started(App) -> + %% @doc Start the skel server. + start() -> + skel_deps:ensure(), +- ensure_started(crypto), + application:start(skel). + + %% @spec stop() -> ok + %% @doc Stop the skel server. + stop() -> + Res = application:stop(skel), +- application:stop(crypto), + Res. +diff --git a/priv/skel/support/run_tests.escript b/priv/skel/support/run_tests.escript +index ff49c06..6ae812c 100755 +--- a/priv/skel/support/run_tests.escript ++++ b/priv/skel/support/run_tests.escript +@@ -18,7 +18,6 @@ main([Ebin]) -> + ModuleNames)], + + +- crypto:start(), + start_cover(Modules), + eunit:test(Modules, [verbose,{report,{eunit_surefire,[{dir,"../_test"}]}}]), + analyze_cover(Modules); +diff --git a/src/mochitemp.erl b/src/mochitemp.erl +index bb23d2a..dc085f4 100644 +--- a/src/mochitemp.erl ++++ b/src/mochitemp.erl +@@ -1,7 +1,7 @@ + %% @author Bob Ippolito + %% @copyright 2010 Mochi Media, Inc. + +-%% @doc Create temporary files and directories. Requires crypto to be started. ++%% @doc Create temporary files and directories. + + -module(mochitemp). + -export([gettempdir/0]). +@@ -84,13 +84,13 @@ rngpath_fun(Prefix, Suffix, Dir) -> + rngchars(0) -> + ""; + rngchars(N) -> +- [rngchar() | rngchars(N - 1)]. ++ [rngchar() | rngchars(N)]. + + rngchar() -> +- rngchar(crypto:rand_uniform(0, tuple_size(?SAFE_CHARS))). ++ rngchar(random:uniform(tuple_size(?SAFE_CHARS))). + + rngchar(C) -> +- element(1 + C, ?SAFE_CHARS). ++ element(C, ?SAFE_CHARS). + + %% @spec gettempdir() -> string() + %% @doc Get a usable temporary directory using the first of these that is a directory: +@@ -176,7 +176,6 @@ gettempdir_cwd_test() -> + ok. + + rngchars_test() -> +- crypto:start(), + ?assertEqual( + "", + rngchars(0)), +@@ -198,7 +197,6 @@ rngchar_test() -> + ok. + + mkdtemp_n_failonce_test() -> +- crypto:start(), + D = mkdtemp(), + Path = filename:join([D, "testdir"]), + %% Toggle the existence of a dir so that it fails +@@ -245,7 +243,6 @@ make_dir_fail_test() -> + ok. + + mkdtemp_test() -> +- crypto:start(), + D = mkdtemp(), + ?assertEqual( + true, +@@ -256,7 +253,6 @@ mkdtemp_test() -> + ok. + + rmtempdir_test() -> +- crypto:start(), + D1 = mkdtemp(), + ?assertEqual( + true, +diff --git a/src/mochiweb.app.src b/src/mochiweb.app.src +index 5664003..a28cde3 100644 +--- a/src/mochiweb.app.src ++++ b/src/mochiweb.app.src +@@ -6,4 +6,4 @@ + {registered, []}, + {mod, {mochiweb_app, []}}, + {env, []}, +- {applications, [kernel, stdlib, crypto, inets]}]}. ++ {applications, [kernel, stdlib, inets]}]}. +diff --git a/src/mochiweb.erl b/src/mochiweb.erl +index 3118028..eee69e8 100644 +--- a/src/mochiweb.erl ++++ b/src/mochiweb.erl +@@ -13,15 +13,12 @@ + %% @spec start() -> ok + %% @doc Start the MochiWeb server. + start() -> +- ensure_started(crypto), + application:start(mochiweb). + + %% @spec stop() -> ok + %% @doc Stop the MochiWeb server. + stop() -> +- Res = application:stop(mochiweb), +- application:stop(crypto), +- Res. ++ application:stop(mochiweb). + + reload() -> + [c:l(Module) || Module <- all_loaded()]. +@@ -78,16 +75,6 @@ new_response({Request, Code, Headers}) -> + Code, + mochiweb_headers:make(Headers)). + +-%% Internal API +- +-ensure_started(App) -> +- case application:start(App) of +- ok -> +- ok; +- {error, {already_started, App}} -> +- ok +- end. +- + + %% + %% Tests +@@ -195,7 +182,7 @@ do_POST(Transport, Size, Times) -> + end, + TestReqs = [begin + Path = "/stuff/" ++ integer_to_list(N), +- Body = crypto:rand_bytes(Size), ++ Body = list_to_binary(mochiweb_util:rand_list(Size)), + #treq{path=Path, body=Body, xreply=Body} + end || N <- lists:seq(1, Times)], + ClientFun = new_client_fun('POST', TestReqs), +diff --git a/src/mochiweb_multipart.erl b/src/mochiweb_multipart.erl +index 3069cf4..f7dc08e 100644 +--- a/src/mochiweb_multipart.erl ++++ b/src/mochiweb_multipart.erl +@@ -38,7 +38,7 @@ parts_to_body([{Start, End, Body}], ContentType, Size) -> + {HeaderList, Body}; + parts_to_body(BodyList, ContentType, Size) when is_list(BodyList) -> + parts_to_multipart_body(BodyList, ContentType, Size, +- mochihex:to_hex(crypto:rand_bytes(8))). ++ mochiweb_util:rand_list(70)). + + %% @spec parts_to_multipart_body([bodypart()], ContentType::string(), + %% Size::integer(), Boundary::string()) -> +diff --git a/src/mochiweb_util.erl b/src/mochiweb_util.erl +index d1cc59d..abdc316 100644 +--- a/src/mochiweb_util.erl ++++ b/src/mochiweb_util.erl +@@ -13,7 +13,7 @@ + -export([record_to_proplist/2, record_to_proplist/3]). + -export([safe_relative_path/1, partition/2]). + -export([parse_qvalues/1, pick_accepted_encodings/3]). +--export([make_io/1]). ++-export([make_io/1, rand_list/1]). + + -define(PERCENT, 37). % $\% + -define(FULLSTOP, 46). % $\. +@@ -545,6 +545,9 @@ make_io(Integer) when is_integer(Integer) -> + make_io(Io) when is_list(Io); is_binary(Io) -> + Io. + ++rand_list(Count) -> ++ [96 + random:uniform(26) || _ <- lists:seq(1, Count)]. ++ + %% + %% Tests + %% +diff --git a/support/run_tests.escript b/support/run_tests.escript +index ff49c06..6ae812c 100755 +--- a/support/run_tests.escript ++++ b/support/run_tests.escript +@@ -18,7 +18,6 @@ main([Ebin]) -> + ModuleNames)], + + +- crypto:start(), + start_cover(Modules), + eunit:test(Modules, [verbose,{report,{eunit_surefire,[{dir,"../_test"}]}}]), + analyze_cover(Modules); diff --git a/deps/rabbitmq_web_dispatch/deps/mochiweb/Makefile b/deps/rabbitmq_web_dispatch/deps/mochiweb/Makefile index 907c46c291..c42ec747c1 100644 --- a/deps/rabbitmq_web_dispatch/deps/mochiweb/Makefile +++ b/deps/rabbitmq_web_dispatch/deps/mochiweb/Makefile @@ -23,7 +23,7 @@ distclean: clean $(LIB_PACKAGE_DIR): $(CHECKOUT_DIR) cp -r $< $@ - cd $@ && patch -p1 < ../mochiweb-12b3.patch + cd $@ && patch -p1 < ../mochiweb-12b3.patch && patch -p1 < ../10-crypto.patch $(CHECKOUT_DIR): git clone $(UPSTREAM_GIT) $@ diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl b/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl index 5d86b38514..bd6aa8027e 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl @@ -6,26 +6,15 @@ -export([static_context_selector/1, static_context_handler/3, static_context_handler/2]). -export([register_authenticated_static_context/5]). -ensure_started(App) -> - case application:start(App) of - ok -> - ok; - {error, {already_started, App}} -> - ok - end. - %% @spec start() -> ok %% @doc Start the rabbit_mochiweb server. start() -> - ensure_started(crypto), application:start(rabbit_mochiweb). %% @spec stop() -> ok %% @doc Stop the rabbit_mochiweb server. stop() -> - Res = application:stop(rabbit_mochiweb), - application:stop(crypto), - Res. + application:stop(rabbit_mochiweb). %% Handler Registration