diff options
author | Loïc Hoguin <[email protected]> | 2014-12-28 19:57:20 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-12-28 19:57:20 +0100 |
commit | 779f4ad51c665092b1da5c8028dad6d62a5f76f0 (patch) | |
tree | 9606496b4ee59fa7092fd6f43eb339adfe1fae43 /src/cow_http_hd.erl | |
parent | 406f5a250ada0a174936bfd498718c2736bf2990 (diff) | |
download | cowlib-779f4ad51c665092b1da5c8028dad6d62a5f76f0.tar.gz cowlib-779f4ad51c665092b1da5c8028dad6d62a5f76f0.tar.bz2 cowlib-779f4ad51c665092b1da5c8028dad6d62a5f76f0.zip |
Add cow_http_hd:parse_pragma/1
We go for an exact <<"no-cache">> match because this is the only
directive that was ever defined, because the header is only kept
for backward compatible reasons with HTTP/1.0 caches, and because
for all other uses the cache-control header is preferred.
Diffstat (limited to 'src/cow_http_hd.erl')
-rw-r--r-- | src/cow_http_hd.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index 6a45fe1..848b8c9 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -39,6 +39,7 @@ -export([parse_if_unmodified_since/1]). -export([parse_last_modified/1]). -export([parse_max_forwards/1]). +-export([parse_pragma/1]). -export([parse_range/1]). -export([parse_retry_after/1]). -export([parse_sec_websocket_accept/1]). @@ -2052,6 +2053,19 @@ parse_max_forwards_error_test_() -> [{V, fun() -> {'EXIT', _} = (catch parse_max_forwards(V)) end} || V <- Tests]. -endif. +%% @doc Parse the Pragma header. +%% +%% Legacy header kept for backward compatibility with HTTP/1.0 caches. +%% Only the "no-cache" directive was ever specified, and only for +%% request messages. +%% +%% We take a large shortcut in the parsing of this header, expecting +%% an exact match of "no-cache". + +-spec parse_pragma(binary()) -> cache | no_cache. +parse_pragma(<<"no-cache">>) -> no_cache; +parse_pragma(_) -> cache. + %% @doc Parse the Range header. -spec parse_range(binary()) |