From faf64524c6758ae1e27404d2ae1383a23538c538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 23 Oct 2013 11:21:31 +0200 Subject: Move cookie parsing/building code to cowlib The code for parsing has also been rewritten to be more efficient and to be able to handle cookie values with space inside them properly. Update cowlib to 0.2.0. --- src/cowboy_clock.erl | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/cowboy_clock.erl') diff --git a/src/cowboy_clock.erl b/src/cowboy_clock.erl index f21616c..6fb522b 100644 --- a/src/cowboy_clock.erl +++ b/src/cowboy_clock.erl @@ -26,7 +26,6 @@ -export([stop/0]). -export([rfc1123/0]). -export([rfc1123/1]). --export([rfc2109/1]). %% gen_server. -export([init/1]). @@ -67,18 +66,6 @@ rfc1123() -> rfc1123(DateTime) -> update_rfc1123(<<>>, undefined, DateTime). -%% @doc Return the given date and time formatted according to RFC-2109. -%% -%% This format is used in the set-cookie header sent with -%% HTTP responses. --spec rfc2109(calendar:datetime()) -> binary(). -rfc2109({Date = {Y, Mo, D}, {H, Mi, S}}) -> - Wday = calendar:day_of_the_week(Date), - << (weekday(Wday))/binary, ", ", (pad_int(D))/binary, "-", - (month(Mo))/binary, "-", (list_to_binary(integer_to_list(Y)))/binary, - " ", (pad_int(H))/binary, $:, (pad_int(Mi))/binary, - $:, (pad_int(S))/binary, " GMT" >>. - %% gen_server. %% @private @@ -188,13 +175,6 @@ month(12) -> <<"Dec">>. -ifdef(TEST). -rfc2109_test_() -> - Tests = [ - {<<"Sat, 14-May-2011 14:25:33 GMT">>, {{2011, 5, 14}, {14, 25, 33}}}, - {<<"Sun, 01-Jan-2012 00:00:00 GMT">>, {{2012, 1, 1}, { 0, 0, 0}}} - ], - [{R, fun() -> R = rfc2109(D) end} || {R, D} <- Tests]. - update_rfc1123_test_() -> Tests = [ {<<"Sat, 14 May 2011 14:25:33 GMT">>, undefined, -- cgit v1.2.3