Browse Source

Erlang/elli add Date header (#3700)

Nate 7 years ago
parent
commit
b3879c76e6
1 changed files with 6 additions and 6 deletions
  1. 6 6
      frameworks/Erlang/elli/src/elli_bench_cb.erl

+ 6 - 6
frameworks/Erlang/elli/src/elli_bench_cb.erl

@@ -8,17 +8,17 @@ handle(Req, _Args) ->
     %% Delegate to our handler function
     handle(Req#req.method, elli_request:path(Req), Req).
 
-%% Plaintext test route 
+%% Plaintext test route
 handle('GET', [<<"plaintext">>], _Req) ->
     %% Reply with a normal response. 'ok' can be used instead of '200'
     %% to signal success.
-    {ok, [{<<"Server">>, <<"elli">>}, {<<"Content-Type">>, <<"text/plain">>}], <<"Hello, World!">>};
+    {ok, [{<<"Server">>, <<"elli">>}, {<<"Date">>, httpd_util:rfc1123_date()}, {<<"Content-Type">>, <<"text/plain">>}], <<"Hello, World!">>};
 
 %% Json test route
 handle('GET',[<<"json">>], _Req) ->
     %% Reply with a normal response. 'ok' can be used instead of '200'
     %% to signal success.
-    {ok, [{<<"Server">>, <<"elli">>}, {<<"Content-Type">>, <<"application/json">>}], jiffy:encode({[{<<"message">>, <<"Hello, World!">>}]})};
+    {ok, [{<<"Server">>, <<"elli">>}, {<<"Date">>, httpd_util:rfc1123_date()}, {<<"Content-Type">>, <<"application/json">>}], jiffy:encode({[{<<"message">>, <<"Hello, World!">>}]})};
 
 %% db test route (Single Database Query)
 handle('GET',[<<"db">>], Req) ->
@@ -29,11 +29,11 @@ handle('GET',[<<"db">>], Req) ->
 			[{[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]}];
 		N ->
 			I = list_to_integer(binary_to_list(N)),
-			Res = [ {[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]} || 
+			Res = [ {[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]} ||
 			        {result_packet, _, _, [[ID, Rand]], _} <- [emysql:execute(test_pool, db_stmt, [random:uniform(10000)]) || _ <- lists:seq(1, I) ]],
 			Res
 		end,
-    {ok, [{<<"Server">>, <<"elli">>}, {<<"Content-Type">>, <<"application/json">>}], jiffy:encode(lists:nth(1,JSON))};
+    {ok, [{<<"Server">>, <<"elli">>}, {<<"Date">>, httpd_util:rfc1123_date()}, {<<"Content-Type">>, <<"application/json">>}], jiffy:encode(lists:nth(1,JSON))};
 
 %% TODO : Finish this function with correct logic.
 %%        Please check TFB document
@@ -46,7 +46,7 @@ handle('GET',[<<"db">>], Req) ->
 %             [{[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]}];
 %         N ->
 %             I = list_to_integer(binary_to_list(N)),
-%             Res = [ {[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]} || 
+%             Res = [ {[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]} ||
 %                     {result_packet, _, _, [[ID, Rand]], _} <- [emysql:execute(test_pool, db_stmt, [random:uniform(10000)]) || _ <- lists:seq(1, I) ]],
 %             Res
 %         end,