0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Small cosmetic changes and doc update to the cookie patch

This commit is contained in:
Loïc Hoguin 2011-07-26 13:58:48 +02:00
parent b75859e075
commit 528d0ebffd
2 changed files with 8 additions and 15 deletions

View file

@ -69,6 +69,10 @@ stop() ->
rfc1123() -> rfc1123() ->
ets:lookup_element(?TABLE, rfc1123, 2). ets:lookup_element(?TABLE, rfc1123, 2).
%% @doc Return the current date and time formatted according to RFC-2109.
%%
%% This format is used in the <em>'Set-Cookie'</em> header sent with
%% HTTP responses.
-spec rfc2109(datetime()) -> binary(). -spec rfc2109(datetime()) -> binary().
rfc2109(LocalTime) -> rfc2109(LocalTime) ->
{{YYYY,MM,DD},{Hour,Min,Sec}} = {{YYYY,MM,DD},{Hour,Min,Sec}} =
@ -91,7 +95,6 @@ rfc2109(LocalTime) ->
MinBin/binary, ":", MinBin/binary, ":",
SecBin/binary, " GMT">>. SecBin/binary, " GMT">>.
%% gen_server. %% gen_server.
%% @private %% @private

View file

@ -17,8 +17,7 @@
-module(cowboy_cookies). -module(cowboy_cookies).
%% API. -export([parse_cookie/1, cookie/3, cookie/2]). %% API.
-export([parse_cookie/1, cookie/3, cookie/2]).
%% Types. %% Types.
-type kv() :: {Name::binary(), Value::binary()}. -type kv() :: {Name::binary(), Value::binary()}.
@ -33,10 +32,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
%% API.
%% ----------------------------------------------------------------------------
%% API
%% ----------------------------------------------------------------------------
%% @doc Parse the contents of a Cookie header field, ignoring cookie %% @doc Parse the contents of a Cookie header field, ignoring cookie
%% attributes, and return a simple property list. %% 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 = <<Cookie/binary, ExpiresPart/binary, SecurePart/binary, DomainPart/binary, PathPart/binary, HttpOnlyPart/binary>>, CookieParts = <<Cookie/binary, ExpiresPart/binary, SecurePart/binary, DomainPart/binary, PathPart/binary, HttpOnlyPart/binary>>,
{<<"Set-Cookie">>, CookieParts}. {<<"Set-Cookie">>, CookieParts}.
%% Internal.
%% ----------------------------------------------------------------------------
%% Private
%% ----------------------------------------------------------------------------
%% @doc Check if a character is a white space character. %% @doc Check if a character is a white space character.
-spec is_whitespace(char()) -> boolean(). -spec is_whitespace(char()) -> boolean().
@ -231,7 +224,6 @@ read_quoted(<<$\\, Any, Rest/binary>>, Acc) ->
read_quoted(<<C, Rest/binary>>, Acc) -> read_quoted(<<C, Rest/binary>>, Acc) ->
read_quoted(Rest, <<Acc/binary, C>>). read_quoted(Rest, <<Acc/binary, C>>).
%% @doc Drop characters while a function returns true. %% @doc Drop characters while a function returns true.
-spec binary_dropwhile(fun((char()) -> boolean()), binary()) -> binary(). -spec binary_dropwhile(fun((char()) -> boolean()), binary()) -> binary().
binary_dropwhile(_F, <<"">>) -> binary_dropwhile(_F, <<"">>) ->
@ -294,9 +286,7 @@ any_to_binary(V) when is_atom(V) ->
any_to_binary(V) when is_integer(V) -> any_to_binary(V) when is_integer(V) ->
list_to_binary(integer_to_list(V)). list_to_binary(integer_to_list(V)).
%% ---------------------------------------------------------------------------- %% Tests.
%% Tests
%% ----------------------------------------------------------------------------
-ifdef(TEST). -ifdef(TEST).