Browse Source

Add cow_http_hd:parse_if_unmodified_since/1

Loïc Hoguin 10 years ago
parent
commit
da7024fb0b
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/cow_http_hd.erl

+ 15 - 0
src/cow_http_hd.erl

@@ -23,6 +23,7 @@
 -export([parse_content_type/1]).
 -export([parse_expect/1]).
 -export([parse_if_modified_since/1]).
+-export([parse_if_unmodified_since/1]).
 -export([parse_max_forwards/1]).
 -export([parse_transfer_encoding/1]).
 
@@ -1008,6 +1009,20 @@ parse_if_modified_since_test_() ->
 	[{V, fun() -> R = parse_if_modified_since(V) end} || {V, R} <- Tests].
 -endif.
 
+%% @doc Parse the If-Unmodified-Since header.
+
+-spec parse_if_unmodified_since(binary()) -> calendar:datetime().
+parse_if_unmodified_since(IfModifiedSince) ->
+	http_date(IfModifiedSince).
+
+-ifdef(TEST).
+parse_if_unmodified_since_test_() ->
+	Tests = [
+		{<<"Sat, 29 Oct 1994 19:43:31 GMT">>, {{1994, 10, 29}, {19, 43, 31}}}
+	],
+	[{V, fun() -> R = parse_if_unmodified_since(V) end} || {V, R} <- Tests].
+-endif.
+
 %% @doc Parse the Max-Forwards header.
 
 -spec parse_max_forwards(binary()) -> integer().