aboutsummaryrefslogtreecommitdiffstats
path: root/src/cow_http_hd.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-12-16 23:14:35 +0200
committerLoïc Hoguin <[email protected]>2014-12-16 23:14:35 +0200
commita2aa7c155496d3dcd02113479dfedbd220c4144b (patch)
tree2c035745c0ace1302efe71c4dc6f344ff31f4f3c /src/cow_http_hd.erl
parentda7024fb0b193a069589d5fde245ccf784bbddb9 (diff)
downloadcowlib-a2aa7c155496d3dcd02113479dfedbd220c4144b.tar.gz
cowlib-a2aa7c155496d3dcd02113479dfedbd220c4144b.tar.bz2
cowlib-a2aa7c155496d3dcd02113479dfedbd220c4144b.zip
Add cow_http_hd:parse_date/1
From RFC7231.
Diffstat (limited to 'src/cow_http_hd.erl')
-rw-r--r--src/cow_http_hd.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl
index 89f9ac9..d2107cf 100644
--- a/src/cow_http_hd.erl
+++ b/src/cow_http_hd.erl
@@ -21,6 +21,7 @@
-export([parse_connection/1]).
-export([parse_content_length/1]).
-export([parse_content_type/1]).
+-export([parse_date/1]).
-export([parse_expect/1]).
-export([parse_if_modified_since/1]).
-export([parse_if_unmodified_since/1]).
@@ -942,6 +943,20 @@ horse_parse_content_type() ->
).
-endif.
+%% @doc Parse the Date header.
+
+-spec parse_date(binary()) -> calendar:datetime().
+parse_date(Date) ->
+ http_date(Date).
+
+-ifdef(TEST).
+parse_date_test_() ->
+ Tests = [
+ {<<"Tue, 15 Nov 1994 08:12:31 GMT">>, {{1994, 11, 15}, {8, 12, 31}}}
+ ],
+ [{V, fun() -> R = parse_date(V) end} || {V, R} <- Tests].
+-endif.
+
%% @doc Parse the Expect header.
-spec parse_expect(binary()) -> continue.