From 528d0ebffd11c8c07259e0e764f3381a12d82418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 26 Jul 2011 13:58:48 +0200 Subject: Small cosmetic changes and doc update to the cookie patch --- src/cowboy_clock.erl | 5 ++++- src/cowboy_cookies.erl | 18 ++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/cowboy_clock.erl b/src/cowboy_clock.erl index 333df94..66fc009 100644 --- a/src/cowboy_clock.erl +++ b/src/cowboy_clock.erl @@ -69,6 +69,10 @@ stop() -> rfc1123() -> ets:lookup_element(?TABLE, rfc1123, 2). +%% @doc Return the current date and time formatted according to RFC-2109. +%% +%% This format is used in the 'Set-Cookie' header sent with +%% HTTP responses. -spec rfc2109(datetime()) -> binary(). rfc2109(LocalTime) -> {{YYYY,MM,DD},{Hour,Min,Sec}} = @@ -91,7 +95,6 @@ rfc2109(LocalTime) -> MinBin/binary, ":", SecBin/binary, " GMT">>. - %% gen_server. %% @private diff --git a/src/cowboy_cookies.erl b/src/cowboy_cookies.erl index 8a11b19..3a50ba6 100644 --- a/src/cowboy_cookies.erl +++ b/src/cowboy_cookies.erl @@ -17,8 +17,7 @@ -module(cowboy_cookies). -%% API. --export([parse_cookie/1, cookie/3, cookie/2]). +-export([parse_cookie/1, cookie/3, cookie/2]). %% API. %% Types. -type kv() :: {Name::binary(), Value::binary()}. @@ -33,10 +32,7 @@ -include_lib("eunit/include/eunit.hrl"). - -%% ---------------------------------------------------------------------------- -%% API -%% ---------------------------------------------------------------------------- +%% API. %% @doc Parse the contents of a Cookie header field, ignoring cookie %% attributes, and return a simple property list. @@ -110,10 +106,7 @@ cookie(Key, Value, Options) when is_binary(Key) andalso is_binary(Value) andalso CookieParts = <>, {<<"Set-Cookie">>, CookieParts}. - -%% ---------------------------------------------------------------------------- -%% Private -%% ---------------------------------------------------------------------------- +%% Internal. %% @doc Check if a character is a white space character. -spec is_whitespace(char()) -> boolean(). @@ -231,7 +224,6 @@ read_quoted(<<$\\, Any, Rest/binary>>, Acc) -> read_quoted(<>, Acc) -> read_quoted(Rest, <>). - %% @doc Drop characters while a function returns true. -spec binary_dropwhile(fun((char()) -> boolean()), binary()) -> binary(). binary_dropwhile(_F, <<"">>) -> @@ -294,9 +286,7 @@ any_to_binary(V) when is_atom(V) -> any_to_binary(V) when is_integer(V) -> list_to_binary(integer_to_list(V)). -%% ---------------------------------------------------------------------------- -%% Tests -%% ---------------------------------------------------------------------------- +%% Tests. -ifdef(TEST). -- cgit v1.2.3