diff -Nru mochiweb-1.5.2+git20110529/debian/changelog mochiweb-1.5.2/debian/changelog --- mochiweb-1.5.2+git20110529/debian/changelog 2011-07-08 09:02:11.000000000 +0000 +++ mochiweb-1.5.2/debian/changelog 2011-07-08 09:02:11.000000000 +0000 @@ -1,22 +1,5 @@ -mochiweb (1.5.2+git20110529-0ppa2) lucid; urgency=low - - * Rename source to mochiweb to match upstream. - * Revert upstream commit b277802, which broke compatibilty with Erlang - R13B03. - * Enable test suite. - - -- William Grant Thu, 07 Jul 2011 09:56:13 +1000 - -erlang-mochiweb (1.5.2+git20110529-0ppa1) natty; urgency=low - - * Use new git snapshot tarball. - * Make binary architecture-independent. - * Install README, examples. - - -- William Grant Wed, 06 Jul 2011 17:34:20 +1000 - -erlang-mochiweb (1.5.2-0ppa1) natty; urgency=low +mochiweb (1.5.2-0ppa1) lucid; urgency=low * Initial release. - -- William Grant Wed, 06 Jul 2011 15:07:49 +1000 + -- William Grant Fri, 08 Jul 2011 18:33:12 +1000 diff -Nru mochiweb-1.5.2+git20110529/debian/control mochiweb-1.5.2/debian/control --- mochiweb-1.5.2+git20110529/debian/control 2011-07-08 09:02:11.000000000 +0000 +++ mochiweb-1.5.2/debian/control 2011-07-08 09:02:11.000000000 +0000 @@ -1,12 +1,11 @@ Source: mochiweb -Section: net -Priority: extra +Section: libs +Priority: optional Maintainer: William Grant -Build-Depends: debhelper (>= 7.0.50~), quilt, erlang-dev, erlang-eunit, +Build-Depends: debhelper (>= 7.0.50~), erlang-dev, erlang-eunit, erlang-tools, erlang-crypto, erlang-xmerl, erlang-syntax-tools -Standards-Version: 3.9.1 +Standards-Version: 3.9.2.0 Homepage: https://github.com/mochi/mochiweb -Vcs-Browser: https://github.com/mochi/mochiweb Package: erlang-mochiweb Architecture: all @@ -14,3 +13,7 @@ erlang-xmerl, erlang-syntax-tools Description: Erlang library for building lightweight HTTP servers MochiWeb is an Erlang library for building lightweight HTTP servers. + . + It is used (in conjunction with eswf and egeoip) to power services such as + MochiBot and MochiAds, which serve dynamically generated SWF content to + millions of viewers daily. diff -Nru mochiweb-1.5.2+git20110529/debian/copyright mochiweb-1.5.2/debian/copyright --- mochiweb-1.5.2+git20110529/debian/copyright 1970-01-01 00:00:00.000000000 +0000 +++ mochiweb-1.5.2/debian/copyright 2011-07-08 09:02:11.000000000 +0000 @@ -0,0 +1,26 @@ +Format: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=174&view=co +Upstream-Name: MochiWeb +Source: https://github.com/mochi/mochiweb + +Files: * +Copyright: 2007-2010 Mochi Media, Inc. +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH + THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff -Nru mochiweb-1.5.2+git20110529/debian/patches/erlang-r13b03-support mochiweb-1.5.2/debian/patches/erlang-r13b03-support --- mochiweb-1.5.2+git20110529/debian/patches/erlang-r13b03-support 2011-07-08 09:02:11.000000000 +0000 +++ mochiweb-1.5.2/debian/patches/erlang-r13b03-support 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -Description: Restore compatibility with Erlang R1303. - Revert upstream commit b277802, as it uses a binary module which - needs Erlang R14A or later. - has discussion. - . - mochiweb_multipart tests now pass. -Origin: upstream, https://github.com/mochi/mochiweb/commit/b277802fe4e464a62a8525a3f0c80653f3139810 - -Index: erlang-mochiweb-1.5.2+git20110529/src/mochiweb_multipart.erl -=================================================================== ---- erlang-mochiweb-1.5.2+git20110529.orig/src/mochiweb_multipart.erl 2011-07-07 09:48:42.839920772 +1000 -+++ erlang-mochiweb-1.5.2+git20110529/src/mochiweb_multipart.erl 2011-07-07 09:49:16.708776419 +1000 -@@ -240,22 +240,24 @@ - S - end. - --%% @spec find_in_binary(Pattern::binary(), Data::binary()) -> --%% {exact, N} | {partial, N, K} | not_found. --%% @doc Searches for the given pattern in the given binary. --find_in_binary(P, Data) when size(P) > 0 -> -- PS = size(P), -- DS = size(Data), -- case DS - PS of -+find_in_binary(B, Data) when size(B) > 0 -> -+ case size(Data) - size(B) of - Last when Last < 0 -> -- partial_find(P, Data, 0, DS); -+ partial_find(B, Data, 0, size(Data)); - Last -> -- case binary:match(Data, P) of -- {Pos, _} -> {exact, Pos}; -- nomatch -> partial_find(P, Data, Last+1, PS-1) -- end -+ find_in_binary(B, size(B), Data, 0, Last) - end. - -+find_in_binary(B, BS, D, N, Last) when N =< Last-> -+ case D of -+ <<_:N/binary, B:BS/binary, _/binary>> -> -+ {exact, N}; -+ _ -> -+ find_in_binary(B, BS, D, 1 + N, Last) -+ end; -+find_in_binary(B, BS, D, N, Last) when N =:= 1 + Last -> -+ partial_find(B, D, N, BS - 1). -+ - partial_find(_B, _D, _N, 0) -> - not_found; - partial_find(B, D, N, K) -> -@@ -376,7 +378,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -412,7 +414,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -449,7 +451,7 @@ - BinContent = iolist_to_binary(Content), - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -502,7 +504,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -554,7 +556,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -607,7 +609,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -683,7 +685,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -731,7 +733,7 @@ - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -+ exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, -@@ -819,54 +821,4 @@ - 10))), - ok. - --%% @todo Move somewhere more appropriate than in the test suite -- --multipart_parsing_benchmark_test() -> -- run_multipart_parsing_benchmark(1). -- --run_multipart_parsing_benchmark(0) -> ok; --run_multipart_parsing_benchmark(N) -> -- multipart_parsing_benchmark(), -- run_multipart_parsing_benchmark(N-1). -- --multipart_parsing_benchmark() -> -- ContentType = "multipart/form-data; boundary=----------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5", -- Chunk = binary:copy(<<"This Is_%Some=Quite0Long4String2Used9For7BenchmarKing.5">>, 102400), -- BinContent = <<"------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"Filename\"\r\n\r\nhello.txt\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"success_action_status\"\r\n\r\n201\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"file\"; filename=\"hello.txt\"\r\nContent-Type: application/octet-stream\r\n\r\n", Chunk/binary, "\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"Upload\"\r\n\r\nSubmit Query\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5--">>, -- Expect = [{headers, -- [{"content-disposition", -- {"form-data", [{"name", "Filename"}]}}]}, -- {body, <<"hello.txt">>}, -- body_end, -- {headers, -- [{"content-disposition", -- {"form-data", [{"name", "success_action_status"}]}}]}, -- {body, <<"201">>}, -- body_end, -- {headers, -- [{"content-disposition", -- {"form-data", [{"name", "file"}, {"filename", "hello.txt"}]}}, -- {"content-type", {"application/octet-stream", []}}]}, -- {body, Chunk}, -- body_end, -- {headers, -- [{"content-disposition", -- {"form-data", [{"name", "Upload"}]}}]}, -- {body, <<"Submit Query">>}, -- body_end, -- eof], -- TestCallback = fun (Next) -> test_callback(Next, Expect) end, -- ServerFun = fun (Socket) -> -- ok = mochiweb_socket:send(Socket, BinContent), -- exit(normal) -- end, -- ClientFun = fun (Socket) -> -- Req = fake_request(Socket, ContentType, -- byte_size(BinContent)), -- Res = parse_multipart_request(Req, TestCallback), -- {0, <<>>, ok} = Res, -- ok -- end, -- ok = with_socket_server(plain, ServerFun, ClientFun), -- ok. - -endif. diff -Nru mochiweb-1.5.2+git20110529/debian/patches/series mochiweb-1.5.2/debian/patches/series --- mochiweb-1.5.2+git20110529/debian/patches/series 2011-07-08 09:02:11.000000000 +0000 +++ mochiweb-1.5.2/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -erlang-r13b03-support diff -Nru mochiweb-1.5.2+git20110529/debian/rules mochiweb-1.5.2/debian/rules --- mochiweb-1.5.2+git20110529/debian/rules 2011-07-08 09:02:11.000000000 +0000 +++ mochiweb-1.5.2/debian/rules 2011-07-08 09:02:11.000000000 +0000 @@ -1,4 +1,4 @@ #!/usr/bin/make -f %: - dh $@ --with quilt + dh $@ diff -Nru mochiweb-1.5.2+git20110529/.gitignore mochiweb-1.5.2/.gitignore --- mochiweb-1.5.2+git20110529/.gitignore 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/.gitignore 2011-03-11 15:55:37.000000000 +0000 @@ -5,5 +5,3 @@ /docs .DS_Store /TEST-*.xml -/deps -*.swp diff -Nru mochiweb-1.5.2+git20110529/README mochiweb-1.5.2/README --- mochiweb-1.5.2+git20110529/README 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/README 2011-03-11 15:55:37.000000000 +0000 @@ -2,10 +2,8 @@ The latest version of MochiWeb is available at http://github.com/mochi/mochiweb -The mailing list for MochiWeb is at http://groups.google.com/group/mochiweb/ - R12B compatibility: -The master of MochiWeb is tested with R14A and later. A branch compatible +The master of MochiWeb is tested with R13B04 and later. A branch compatible with R12B is maintained separately at http://github.com/lemenkov/mochiweb The R12B branch of that repository is mirrored in the official repository occasionally for convenience. diff -Nru mochiweb-1.5.2+git20110529/rebar.config mochiweb-1.5.2/rebar.config --- mochiweb-1.5.2+git20110529/rebar.config 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/rebar.config 2011-03-11 15:55:37.000000000 +0000 @@ -3,14 +3,3 @@ {cover_enabled, true}. {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}. {template_dir, "support/templates/"}. -{dialyzer_opts, [{warnings, [no_return, - no_unused, - no_improper_lists, - no_fun_app, - no_match, - no_opaque, - no_fail_call, - error_handling, - race_conditions, - behaviours, - unmatched_returns]}]}. diff -Nru mochiweb-1.5.2+git20110529/src/mochiglobal.erl mochiweb-1.5.2/src/mochiglobal.erl --- mochiweb-1.5.2+git20110529/src/mochiglobal.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiglobal.erl 2011-03-11 15:55:37.000000000 +0000 @@ -30,7 +30,7 @@ put(_K, V, Mod) -> Bin = compile(Mod, V), code:purge(Mod), - {module, Mod} = code:load_binary(Mod, atom_to_list(Mod) ++ ".erl", Bin), + code:load_binary(Mod, atom_to_list(Mod) ++ ".erl", Bin), ok. -spec delete(atom()) -> boolean(). diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_app.erl mochiweb-1.5.2/src/mochiweb_app.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_app.erl 1970-01-01 00:00:00.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_app.erl 2011-03-11 15:55:37.000000000 +0000 @@ -0,0 +1,27 @@ +%% @author Bob Ippolito +%% @copyright 2007 Mochi Media, Inc. + +%% @doc Callbacks for the mochiweb application. + +-module(mochiweb_app). +-author('bob@mochimedia.com'). + +-behaviour(application). +-export([start/2,stop/1]). + +%% @spec start(_Type, _StartArgs) -> ServerRet +%% @doc application start callback for mochiweb. +start(_Type, _StartArgs) -> + mochiweb_sup:start_link(). + +%% @spec stop(_State) -> ServerRet +%% @doc application stop callback for mochiweb. +stop(_State) -> + ok. + +%% +%% Tests +%% +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). +-endif. diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb.app.src mochiweb-1.5.2/src/mochiweb.app.src --- mochiweb-1.5.2+git20110529/src/mochiweb.app.src 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb.app.src 2011-03-11 15:55:37.000000000 +0000 @@ -1,9 +1,9 @@ %% This is generated from src/mochiweb.app.src {application, mochiweb, [{description, "MochiMedia Web Server"}, - {vsn, "2.0.0"}, + {vsn, "1.5.2"}, {modules, []}, {registered, []}, + {mod, {mochiweb_app, []}}, {env, []}, - {applications, [kernel, stdlib, crypto, inets, ssl, xmerl, - compiler, syntax_tools]}]}. + {applications, [kernel, stdlib, crypto, inets]}]}. diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_cookies.erl mochiweb-1.5.2/src/mochiweb_cookies.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_cookies.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_cookies.erl 2011-03-11 15:55:37.000000000 +0000 @@ -116,26 +116,12 @@ orelse erlang:error({cookie_quoting_required, V}), V. - -%% Return a date in the form of: Wdy, DD-Mon-YYYY HH:MM:SS GMT -%% See also: rfc2109: 10.1.2 -rfc2109_cookie_expires_date(LocalTime) -> - {{YYYY,MM,DD},{Hour,Min,Sec}} = - case calendar:local_time_to_universal_time_dst(LocalTime) of - [Gmt] -> Gmt; - [_,Gmt] -> Gmt - end, - DayNumber = calendar:day_of_the_week({YYYY,MM,DD}), - lists:flatten( - io_lib:format("~s, ~2.2.0w-~3.s-~4.4.0w ~2.2.0w:~2.2.0w:~2.2.0w GMT", - [httpd_util:day(DayNumber),DD,httpd_util:month(MM),YYYY,Hour,Min,Sec])). - add_seconds(Secs, LocalTime) -> Greg = calendar:datetime_to_gregorian_seconds(LocalTime), calendar:gregorian_seconds_to_datetime(Greg + Secs). age_to_cookie_date(Age, LocalTime) -> - rfc2109_cookie_expires_date(add_seconds(Age, LocalTime)). + httpd_util:rfc1123_date(add_seconds(Age, LocalTime)). %% @spec parse_cookie(string()) -> [{K::string(), V::string()}] %% @doc Parse the contents of a Cookie header field, ignoring cookie @@ -308,14 +294,14 @@ C2 = {"Set-Cookie", "Customer=WILE_E_COYOTE; " "Version=1; " - "Expires=Tue, 15-May-2007 13:45:33 GMT; " + "Expires=Tue, 15 May 2007 13:45:33 GMT; " "Max-Age=0"}, C2 = cookie("Customer", "WILE_E_COYOTE", [{max_age, -111}, {local_time, LocalTime}]), C3 = {"Set-Cookie", "Customer=WILE_E_COYOTE; " "Version=1; " - "Expires=Wed, 16-May-2007 13:45:50 GMT; " + "Expires=Wed, 16 May 2007 13:45:50 GMT; " "Max-Age=86417"}, C3 = cookie("Customer", "WILE_E_COYOTE", [{max_age, 86417}, {local_time, LocalTime}]), diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb.erl mochiweb-1.5.2/src/mochiweb.erl --- mochiweb-1.5.2+git20110529/src/mochiweb.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb.erl 2011-03-11 15:55:37.000000000 +0000 @@ -6,9 +6,22 @@ -module(mochiweb). -author('bob@mochimedia.com'). +-export([start/0, stop/0]). -export([new_request/1, new_response/1]). -export([all_loaded/0, all_loaded/1, reload/0]). --export([ensure_started/1]). + +%% @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. reload() -> [c:l(Module) || Module <- all_loaded()]. @@ -65,8 +78,8 @@ Code, mochiweb_headers:make(Headers)). -%% @spec ensure_started(App::atom()) -> ok -%% @doc Start the given App if it has not been started already. +%% Internal API + ensure_started(App) -> case application:start(App) of ok -> @@ -75,6 +88,7 @@ ok end. + %% %% Tests %% @@ -124,11 +138,11 @@ do_GET(ssl, 3). hundred_http_GET_test_() -> % note the underscore - {timeout, ?LARGE_TIMEOUT, + {timeout, ?LARGE_TIMEOUT, fun() -> ?assertEqual(ok, do_GET(plain,100)) end}. hundred_https_GET_test_() -> % note the underscore - {timeout, ?LARGE_TIMEOUT, + {timeout, ?LARGE_TIMEOUT, fun() -> ?assertEqual(ok, do_GET(ssl,100)) end}. single_128_http_POST_test() -> @@ -156,11 +170,11 @@ do_POST(ssl, 102400, 3). hundred_128_http_POST_test_() -> % note the underscore - {timeout, ?LARGE_TIMEOUT, + {timeout, ?LARGE_TIMEOUT, fun() -> ?assertEqual(ok, do_POST(plain, 128, 100)) end}. hundred_128_https_POST_test_() -> % note the underscore - {timeout, ?LARGE_TIMEOUT, + {timeout, ?LARGE_TIMEOUT, fun() -> ?assertEqual(ok, do_POST(ssl, 128, 100)) end}. do_GET(Transport, Times) -> diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_http.erl mochiweb-1.5.2/src/mochiweb_http.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_http.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_http.erl 2011-03-11 15:55:37.000000000 +0000 @@ -96,14 +96,14 @@ default_body(Req, Req:get(method), Req:get(path)). loop(Socket, Body) -> - ok = mochiweb_socket:setopts(Socket, [{packet, http}]), + mochiweb_socket:setopts(Socket, [{packet, http}]), request(Socket, Body). request(Socket, Body) -> - ok = mochiweb_socket:setopts(Socket, [{active, once}]), + mochiweb_socket:setopts(Socket, [{active, once}]), receive {Protocol, _, {http_request, Method, Path, Version}} when Protocol == http orelse Protocol == ssl -> - ok = mochiweb_socket:setopts(Socket, [{packet, httph}]), + mochiweb_socket:setopts(Socket, [{packet, httph}]), headers(Socket, {Method, Path, Version}, [], Body, 0); {Protocol, _, {http_error, "\r\n"}} when Protocol == http orelse Protocol == ssl -> request(Socket, Body); @@ -126,10 +126,10 @@ headers(Socket, Request, Headers, _Body, ?MAX_HEADERS) -> %% Too many headers sent, bad request. - ok = mochiweb_socket:setopts(Socket, [{packet, raw}]), + mochiweb_socket:setopts(Socket, [{packet, raw}]), handle_invalid_request(Socket, Request, Headers); headers(Socket, Request, Headers, Body, HeaderCount) -> - ok = mochiweb_socket:setopts(Socket, [{active, once}]), + mochiweb_socket:setopts(Socket, [{active, once}]), receive {Protocol, _, http_eoh} when Protocol == http orelse Protocol == ssl -> Req = new_request(Socket, Request, Headers), @@ -155,12 +155,10 @@ call_body(Body, Req) -> Body(Req). --spec handle_invalid_request(term()) -> no_return(). handle_invalid_request(Socket) -> handle_invalid_request(Socket, {'GET', {abs_path, "/"}, {0,9}}, []), exit(normal). --spec handle_invalid_request(term(), term(), term()) -> no_return(). handle_invalid_request(Socket, Request, RevHeaders) -> Req = new_request(Socket, Request, RevHeaders), Req:respond({400, [], []}), @@ -168,7 +166,7 @@ exit(normal). new_request(Socket, Request, RevHeaders) -> - ok = mochiweb_socket:setopts(Socket, [{packet, raw}]), + mochiweb_socket:setopts(Socket, [{packet, raw}]), mochiweb:new_request({Socket, Request, lists:reverse(RevHeaders)}). after_response(Body, Req) -> diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_mime.erl mochiweb-1.5.2/src/mochiweb_mime.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_mime.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_mime.erl 2011-03-11 15:55:37.000000000 +0000 @@ -11,361 +11,62 @@ %% @doc Given a filename extension (e.g. ".html") return a guess for the MIME %% type such as "text/html". Will return the atom undefined if no good %% guess is available. - -from_extension(".stl") -> - "application/SLA"; -from_extension(".stp") -> - "application/STEP"; -from_extension(".step") -> - "application/STEP"; -from_extension(".dwg") -> - "application/acad"; -from_extension(".ez") -> - "application/andrew-inset"; -from_extension(".ccad") -> - "application/clariscad"; -from_extension(".drw") -> - "application/drafting"; -from_extension(".tsp") -> - "application/dsptype"; -from_extension(".dxf") -> - "application/dxf"; -from_extension(".xls") -> - "application/excel"; -from_extension(".unv") -> - "application/i-deas"; -from_extension(".jar") -> - "application/java-archive"; -from_extension(".hqx") -> - "application/mac-binhex40"; -from_extension(".cpt") -> - "application/mac-compactpro"; -from_extension(".pot") -> - "application/vnd.ms-powerpoint"; -from_extension(".ppt") -> - "application/vnd.ms-powerpoint"; -from_extension(".dms") -> - "application/octet-stream"; -from_extension(".lha") -> - "application/octet-stream"; -from_extension(".lzh") -> - "application/octet-stream"; -from_extension(".oda") -> - "application/oda"; -from_extension(".ogg") -> - "application/ogg"; -from_extension(".ogm") -> - "application/ogg"; -from_extension(".pdf") -> - "application/pdf"; -from_extension(".pgp") -> - "application/pgp"; -from_extension(".ai") -> - "application/postscript"; -from_extension(".eps") -> - "application/postscript"; -from_extension(".ps") -> - "application/postscript"; -from_extension(".prt") -> - "application/pro_eng"; -from_extension(".rtf") -> - "application/rtf"; -from_extension(".smi") -> - "application/smil"; -from_extension(".smil") -> - "application/smil"; -from_extension(".sol") -> - "application/solids"; -from_extension(".vda") -> - "application/vda"; -from_extension(".xlm") -> - "application/vnd.ms-excel"; -from_extension(".cod") -> - "application/vnd.rim.cod"; -from_extension(".pgn") -> - "application/x-chess-pgn"; -from_extension(".cpio") -> - "application/x-cpio"; -from_extension(".csh") -> - "application/x-csh"; -from_extension(".deb") -> - "application/x-debian-package"; -from_extension(".dcr") -> - "application/x-director"; -from_extension(".dir") -> - "application/x-director"; -from_extension(".dxr") -> - "application/x-director"; -from_extension(".gz") -> - "application/x-gzip"; -from_extension(".hdf") -> - "application/x-hdf"; -from_extension(".ipx") -> - "application/x-ipix"; -from_extension(".ips") -> - "application/x-ipscript"; +from_extension(".html") -> + "text/html"; +from_extension(".xhtml") -> + "application/xhtml+xml"; +from_extension(".xml") -> + "application/xml"; +from_extension(".css") -> + "text/css"; from_extension(".js") -> "application/x-javascript"; -from_extension(".skd") -> - "application/x-koan"; -from_extension(".skm") -> - "application/x-koan"; -from_extension(".skp") -> - "application/x-koan"; -from_extension(".skt") -> - "application/x-koan"; -from_extension(".latex") -> - "application/x-latex"; -from_extension(".lsp") -> - "application/x-lisp"; -from_extension(".scm") -> - "application/x-lotusscreencam"; -from_extension(".mif") -> - "application/x-mif"; -from_extension(".com") -> - "application/x-msdos-program"; -from_extension(".exe") -> - "application/octet-stream"; -from_extension(".cdf") -> - "application/x-netcdf"; -from_extension(".nc") -> - "application/x-netcdf"; -from_extension(".pl") -> - "application/x-perl"; -from_extension(".pm") -> - "application/x-perl"; -from_extension(".rar") -> - "application/x-rar-compressed"; -from_extension(".sh") -> - "application/x-sh"; -from_extension(".shar") -> - "application/x-shar"; -from_extension(".swf") -> - "application/x-shockwave-flash"; -from_extension(".sit") -> - "application/x-stuffit"; -from_extension(".sv4cpio") -> - "application/x-sv4cpio"; -from_extension(".sv4crc") -> - "application/x-sv4crc"; -from_extension(".tar.gz") -> - "application/x-tar-gz"; -from_extension(".tgz") -> - "application/x-tar-gz"; -from_extension(".tar") -> - "application/x-tar"; -from_extension(".tcl") -> - "application/x-tcl"; -from_extension(".texi") -> - "application/x-texinfo"; -from_extension(".texinfo") -> - "application/x-texinfo"; -from_extension(".man") -> - "application/x-troff-man"; -from_extension(".me") -> - "application/x-troff-me"; -from_extension(".ms") -> - "application/x-troff-ms"; -from_extension(".roff") -> - "application/x-troff"; -from_extension(".t") -> - "application/x-troff"; -from_extension(".tr") -> - "application/x-troff"; -from_extension(".ustar") -> - "application/x-ustar"; -from_extension(".src") -> - "application/x-wais-source"; -from_extension(".zip") -> - "application/zip"; -from_extension(".tsi") -> - "audio/TSP-audio"; -from_extension(".au") -> - "audio/basic"; -from_extension(".snd") -> - "audio/basic"; -from_extension(".kar") -> - "audio/midi"; -from_extension(".mid") -> - "audio/midi"; -from_extension(".midi") -> - "audio/midi"; -from_extension(".mp2") -> - "audio/mpeg"; -from_extension(".mp3") -> - "audio/mpeg"; -from_extension(".mpga") -> - "audio/mpeg"; -from_extension(".aif") -> - "audio/x-aiff"; -from_extension(".aifc") -> - "audio/x-aiff"; -from_extension(".aiff") -> - "audio/x-aiff"; -from_extension(".m3u") -> - "audio/x-mpegurl"; -from_extension(".wax") -> - "audio/x-ms-wax"; -from_extension(".wma") -> - "audio/x-ms-wma"; -from_extension(".rpm") -> - "audio/x-pn-realaudio-plugin"; -from_extension(".ram") -> - "audio/x-pn-realaudio"; -from_extension(".rm") -> - "audio/x-pn-realaudio"; -from_extension(".ra") -> - "audio/x-realaudio"; -from_extension(".wav") -> - "audio/x-wav"; -from_extension(".pdb") -> - "chemical/x-pdb"; -from_extension(".ras") -> - "image/cmu-raster"; -from_extension(".gif") -> - "image/gif"; -from_extension(".ief") -> - "image/ief"; -from_extension(".jpe") -> - "image/jpeg"; -from_extension(".jpeg") -> - "image/jpeg"; from_extension(".jpg") -> "image/jpeg"; -from_extension(".jp2") -> - "image/jp2"; +from_extension(".gif") -> + "image/gif"; from_extension(".png") -> "image/png"; -from_extension(".tif") -> - "image/tiff"; -from_extension(".tiff") -> - "image/tiff"; -from_extension(".pnm") -> - "image/x-portable-anymap"; -from_extension(".pbm") -> - "image/x-portable-bitmap"; -from_extension(".pgm") -> - "image/x-portable-graymap"; -from_extension(".ppm") -> - "image/x-portable-pixmap"; -from_extension(".rgb") -> - "image/x-rgb"; -from_extension(".xbm") -> - "image/x-xbitmap"; -from_extension(".xwd") -> - "image/x-xwindowdump"; -from_extension(".iges") -> - "model/iges"; -from_extension(".igs") -> - "model/iges"; -from_extension(".mesh") -> - "model/mesh"; -from_extension(".") -> - ""; -from_extension(".msh") -> - "model/mesh"; -from_extension(".silo") -> - "model/mesh"; -from_extension(".vrml") -> - "model/vrml"; -from_extension(".wrl") -> - "model/vrml"; -from_extension(".css") -> - "text/css"; -from_extension(".htm") -> - "text/html"; -from_extension(".html") -> - "text/html"; -from_extension(".asc") -> - "text/plain"; -from_extension(".c") -> - "text/plain"; -from_extension(".cc") -> - "text/plain"; -from_extension(".f90") -> - "text/plain"; -from_extension(".f") -> - "text/plain"; -from_extension(".hh") -> - "text/plain"; -from_extension(".m") -> - "text/plain"; -from_extension(".txt") -> - "text/plain"; -from_extension(".rtx") -> - "text/richtext"; -from_extension(".sgm") -> - "text/sgml"; -from_extension(".sgml") -> - "text/sgml"; -from_extension(".tsv") -> - "text/tab-separated-values"; -from_extension(".jad") -> - "text/vnd.sun.j2me.app-descriptor"; -from_extension(".etx") -> - "text/x-setext"; -from_extension(".xml") -> - "application/xml"; -from_extension(".dl") -> - "video/dl"; -from_extension(".fli") -> - "video/fli"; -from_extension(".flv") -> - "video/flv"; -from_extension(".gl") -> - "video/gl"; -from_extension(".mp4") -> - "video/mp4"; -from_extension(".mpe") -> - "video/mpeg"; -from_extension(".mpeg") -> - "video/mpeg"; -from_extension(".mpg") -> - "video/mpeg"; -from_extension(".mov") -> - "video/quicktime"; -from_extension(".qt") -> - "video/quicktime"; -from_extension(".viv") -> - "video/vnd.vivo"; -from_extension(".vivo") -> - "video/vnd.vivo"; -from_extension(".asf") -> - "video/x-ms-asf"; -from_extension(".asx") -> - "video/x-ms-asx"; -from_extension(".wmv") -> - "video/x-ms-wmv"; -from_extension(".wmx") -> - "video/x-ms-wmx"; -from_extension(".wvx") -> - "video/x-ms-wvx"; -from_extension(".avi") -> - "video/x-msvideo"; -from_extension(".movie") -> - "video/x-sgi-movie"; -from_extension(".mime") -> - "www/mime"; -from_extension(".ice") -> - "x-conference/x-cooltalk"; -from_extension(".vrm") -> - "x-world/x-vrml"; -from_extension(".spx") -> - "audio/ogg"; -from_extension(".xhtml") -> - "application/xhtml+xml"; +from_extension(".swf") -> + "application/x-shockwave-flash"; +from_extension(".zip") -> + "application/zip"; from_extension(".bz2") -> "application/x-bzip2"; +from_extension(".gz") -> + "application/x-gzip"; +from_extension(".tar") -> + "application/x-tar"; +from_extension(".tgz") -> + "application/x-gzip"; +from_extension(".txt") -> + "text/plain"; from_extension(".doc") -> "application/msword"; +from_extension(".pdf") -> + "application/pdf"; +from_extension(".xls") -> + "application/vnd.ms-excel"; +from_extension(".rtf") -> + "application/rtf"; +from_extension(".mov") -> + "video/quicktime"; +from_extension(".mp3") -> + "audio/mpeg"; from_extension(".z") -> "application/x-compress"; +from_extension(".wav") -> + "audio/x-wav"; from_extension(".ico") -> "image/x-icon"; from_extension(".bmp") -> "image/bmp"; from_extension(".m4a") -> "audio/mpeg"; +from_extension(".m3u") -> + "audio/x-mpegurl"; +from_extension(".exe") -> + "application/octet-stream"; from_extension(".csv") -> "text/csv"; from_extension(_) -> diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_multipart.erl mochiweb-1.5.2/src/mochiweb_multipart.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_multipart.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_multipart.erl 2011-03-11 15:55:37.000000000 +0000 @@ -240,22 +240,24 @@ S end. -%% @spec find_in_binary(Pattern::binary(), Data::binary()) -> -%% {exact, N} | {partial, N, K} | not_found. -%% @doc Searches for the given pattern in the given binary. -find_in_binary(P, Data) when size(P) > 0 -> - PS = size(P), - DS = size(Data), - case DS - PS of +find_in_binary(B, Data) when size(B) > 0 -> + case size(Data) - size(B) of Last when Last < 0 -> - partial_find(P, Data, 0, DS); + partial_find(B, Data, 0, size(Data)); Last -> - case binary:match(Data, P) of - {Pos, _} -> {exact, Pos}; - nomatch -> partial_find(P, Data, Last+1, PS-1) - end + find_in_binary(B, size(B), Data, 0, Last) end. +find_in_binary(B, BS, D, N, Last) when N =< Last-> + case D of + <<_:N/binary, B:BS/binary, _/binary>> -> + {exact, N}; + _ -> + find_in_binary(B, BS, D, 1 + N, Last) + end; +find_in_binary(B, BS, D, N, Last) when N =:= 1 + Last -> + partial_find(B, D, N, BS - 1). + partial_find(_B, _D, _N, 0) -> not_found; partial_find(B, D, N, K) -> @@ -376,7 +378,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -412,7 +414,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -449,7 +451,7 @@ BinContent = iolist_to_binary(Content), ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -502,7 +504,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -554,7 +556,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -607,7 +609,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -683,7 +685,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -731,7 +733,7 @@ TestCallback = fun (Next) -> test_callback(Next, Expect) end, ServerFun = fun (Socket) -> ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) + exit(normal) end, ClientFun = fun (Socket) -> Req = fake_request(Socket, ContentType, @@ -819,54 +821,4 @@ 10))), ok. -%% @todo Move somewhere more appropriate than in the test suite - -multipart_parsing_benchmark_test() -> - run_multipart_parsing_benchmark(1). - -run_multipart_parsing_benchmark(0) -> ok; -run_multipart_parsing_benchmark(N) -> - multipart_parsing_benchmark(), - run_multipart_parsing_benchmark(N-1). - -multipart_parsing_benchmark() -> - ContentType = "multipart/form-data; boundary=----------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5", - Chunk = binary:copy(<<"This Is_%Some=Quite0Long4String2Used9For7BenchmarKing.5">>, 102400), - BinContent = <<"------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"Filename\"\r\n\r\nhello.txt\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"success_action_status\"\r\n\r\n201\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"file\"; filename=\"hello.txt\"\r\nContent-Type: application/octet-stream\r\n\r\n", Chunk/binary, "\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5\r\nContent-Disposition: form-data; name=\"Upload\"\r\n\r\nSubmit Query\r\n------------ei4GI3GI3Ij5Ef1ae0KM7Ij5ei4Ij5--">>, - Expect = [{headers, - [{"content-disposition", - {"form-data", [{"name", "Filename"}]}}]}, - {body, <<"hello.txt">>}, - body_end, - {headers, - [{"content-disposition", - {"form-data", [{"name", "success_action_status"}]}}]}, - {body, <<"201">>}, - body_end, - {headers, - [{"content-disposition", - {"form-data", [{"name", "file"}, {"filename", "hello.txt"}]}}, - {"content-type", {"application/octet-stream", []}}]}, - {body, Chunk}, - body_end, - {headers, - [{"content-disposition", - {"form-data", [{"name", "Upload"}]}}]}, - {body, <<"Submit Query">>}, - body_end, - eof], - TestCallback = fun (Next) -> test_callback(Next, Expect) end, - ServerFun = fun (Socket) -> - ok = mochiweb_socket:send(Socket, BinContent), - exit(normal) - end, - ClientFun = fun (Socket) -> - Req = fake_request(Socket, ContentType, - byte_size(BinContent)), - Res = parse_multipart_request(Req, TestCallback), - {0, <<>>, ok} = Res, - ok - end, - ok = with_socket_server(plain, ServerFun, ClientFun), - ok. -endif. diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_request.erl mochiweb-1.5.2/src/mochiweb_request.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_request.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_request.erl 2011-03-11 15:55:37.000000000 +0000 @@ -223,8 +223,7 @@ end, case Expect of "100-continue" -> - _ = start_raw_response({100, gb_trees:empty()}), - ok; + start_raw_response({100, gb_trees:empty()}); _Else -> ok end, @@ -400,11 +399,14 @@ %% @doc Clean up any junk in the process dictionary, required before continuing %% a Keep-Alive request. cleanup() -> - L = [?SAVE_QS, ?SAVE_PATH, ?SAVE_RECV, ?SAVE_BODY, ?SAVE_BODY_LENGTH, - ?SAVE_POST, ?SAVE_COOKIE, ?SAVE_FORCE_CLOSE], - lists:foreach(fun(K) -> - erase(K) - end, L), + [erase(K) || K <- [?SAVE_QS, + ?SAVE_PATH, + ?SAVE_RECV, + ?SAVE_BODY, + ?SAVE_BODY_LENGTH, + ?SAVE_POST, + ?SAVE_COOKIE, + ?SAVE_FORCE_CLOSE]], ok. %% @spec parse_qs() -> [{Key::string(), Value::string()}] @@ -496,10 +498,10 @@ %% @spec read_chunk_length() -> integer() %% @doc Read the length of the next HTTP chunk. read_chunk_length() -> - ok = mochiweb_socket:setopts(Socket, [{packet, line}]), + mochiweb_socket:setopts(Socket, [{packet, line}]), case mochiweb_socket:recv(Socket, 0, ?IDLE_TIMEOUT) of {ok, Header} -> - ok = mochiweb_socket:setopts(Socket, [{packet, raw}]), + mochiweb_socket:setopts(Socket, [{packet, raw}]), Splitter = fun (C) -> C =/= $\r andalso C =/= $\n andalso C =/= $ end, @@ -513,7 +515,7 @@ %% @doc Read in a HTTP chunk of the given length. If Length is 0, then read the %% HTTP footers (as a list of binaries, since they're nominal). read_chunk(0) -> - ok = mochiweb_socket:setopts(Socket, [{packet, line}]), + mochiweb_socket:setopts(Socket, [{packet, line}]), F = fun (F1, Acc) -> case mochiweb_socket:recv(Socket, 0, ?IDLE_TIMEOUT) of {ok, <<"\r\n">>} -> @@ -525,7 +527,7 @@ end end, Footers = F(F, []), - ok = mochiweb_socket:setopts(Socket, [{packet, raw}]), + mochiweb_socket:setopts(Socket, [{packet, raw}]), put(?SAVE_RECV, true), Footers; read_chunk(Length) -> @@ -610,7 +612,7 @@ [{"last-modified", LastModified} | ExtraHeaders], {file, IoDevice}}), - ok = file:close(IoDevice), + file:close(IoDevice), Res; _ -> not_found(ExtraHeaders) diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_socket_server.erl mochiweb-1.5.2/src/mochiweb_socket_server.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_socket_server.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_socket_server.erl 2011-03-11 15:55:37.000000000 +0000 @@ -119,11 +119,11 @@ start_server(State=#mochiweb_socket_server{ssl=Ssl, name=Name}) -> case Ssl of true -> - ok = mochiweb:ensure_started(crypto), - ok = mochiweb:ensure_started(public_key), - ok = mochiweb:ensure_started(ssl); + application:start(crypto), + application:start(public_key), + application:start(ssl); false -> - ok + void end, case Name of undefined -> @@ -165,7 +165,27 @@ {_, _, _, _, _, _, _, _} -> % IPv6 [inet6, {ip, Ip} | BaseOpts] end, - listen(Port, Opts, State). + case listen(Port, Opts, State) of + {stop, eacces} -> + case Port < 1024 of + true -> + case catch fdsrv:start() of + {ok, _} -> + case fdsrv:bind_socket(tcp, Port) of + {ok, Fd} -> + listen(Port, [{fd, Fd} | Opts], State); + _ -> + {stop, fdsrv_bind_failed} + end; + _ -> + {stop, fdsrv_start_failed} + end; + false -> + {stop, eacces} + end; + Other -> + Other + end. new_acceptor_pool(Listen, State=#mochiweb_socket_server{acceptor_pool=Pool, @@ -251,8 +271,15 @@ terminate(Reason, State) when ?is_old_state(State) -> terminate(Reason, upgrade_state(State)); -terminate(_Reason, #mochiweb_socket_server{listen=Listen}) -> - mochiweb_socket:close(Listen). +terminate(_Reason, #mochiweb_socket_server{listen=Listen, port=Port}) -> + mochiweb_socket:close(Listen), + case Port < 1024 of + true -> + catch fdsrv:stop(), + ok; + false -> + ok + end. code_change(_OldVsn, State, _Extra) -> State. @@ -334,3 +361,4 @@ ?assertEqual(CmpState, State). -endif. + diff -Nru mochiweb-1.5.2+git20110529/src/mochiweb_sup.erl mochiweb-1.5.2/src/mochiweb_sup.erl --- mochiweb-1.5.2+git20110529/src/mochiweb_sup.erl 1970-01-01 00:00:00.000000000 +0000 +++ mochiweb-1.5.2/src/mochiweb_sup.erl 2011-03-11 15:55:37.000000000 +0000 @@ -0,0 +1,41 @@ +%% @author Bob Ippolito +%% @copyright 2007 Mochi Media, Inc. + +%% @doc Supervisor for the mochiweb application. + +-module(mochiweb_sup). +-author('bob@mochimedia.com'). + +-behaviour(supervisor). + +%% External exports +-export([start_link/0, upgrade/0]). + +%% supervisor callbacks +-export([init/1]). + +%% @spec start_link() -> ServerRet +%% @doc API for starting the supervisor. +start_link() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). + +%% @spec upgrade() -> ok +%% @doc Add processes if necessary. +upgrade() -> + {ok, {_, Specs}} = init([]), + lists:foreach(fun(S) -> supervisor:start_child(?MODULE, S) end, Specs), + ok. + +%% @spec init([]) -> SupervisorTree +%% @doc supervisor callback, ensures yaws is in embedded mode and then +%% returns the supervisor tree. +init([]) -> + Processes = [], + {ok, {{one_for_one, 10, 10}, Processes}}. + +%% +%% Tests +%% +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). +-endif. diff -Nru mochiweb-1.5.2+git20110529/src/reloader.erl mochiweb-1.5.2/src/reloader.erl --- mochiweb-1.5.2+git20110529/src/reloader.erl 2011-05-28 15:49:15.000000000 +0000 +++ mochiweb-1.5.2/src/reloader.erl 2011-03-11 15:55:37.000000000 +0000 @@ -59,7 +59,7 @@ %% @doc gen_server callback. handle_info(doit, State) -> Now = stamp(), - _ = doit(State#state.last, Now), + doit(State#state.last, Now), {noreply, State#state{last = Now}}; handle_info(_Info, State) -> {noreply, State}.