From 38f9b0cf699cb57aa8384128ca5c34ee93df57a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 16 Dec 2014 23:20:16 +0200 Subject: Add cow_http_hd:parse_last_modified/1 From RFC7232. --- src/cow_http_hd.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index d2107cf..5add28a 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -25,6 +25,7 @@ -export([parse_expect/1]). -export([parse_if_modified_since/1]). -export([parse_if_unmodified_since/1]). +-export([parse_last_modified/1]). -export([parse_max_forwards/1]). -export([parse_transfer_encoding/1]). @@ -1038,6 +1039,20 @@ parse_if_unmodified_since_test_() -> [{V, fun() -> R = parse_if_unmodified_since(V) end} || {V, R} <- Tests]. -endif. +%% @doc Parse the Last-Modified header. + +-spec parse_last_modified(binary()) -> calendar:datetime(). +parse_last_modified(LastModified) -> + http_date(LastModified). + +-ifdef(TEST). +parse_last_modified_test_() -> + Tests = [ + {<<"Tue, 15 Nov 1994 12:45:26 GMT">>, {{1994, 11, 15}, {12, 45, 26}}} + ], + [{V, fun() -> R = parse_last_modified(V) end} || {V, R} <- Tests]. +-endif. + %% @doc Parse the Max-Forwards header. -spec parse_max_forwards(binary()) -> integer(). -- cgit v1.2.3