From 779f4ad51c665092b1da5c8028dad6d62a5f76f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 28 Dec 2014 19:57:20 +0100 Subject: 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. --- src/cow_http_hd.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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()) -- cgit v1.2.3