#ifndef CacheValidation_h
#define CacheValidation_h
#include "PlatformExportMacros.h"
#include "SessionID.h"
#include <wtf/Optional.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class HTTPHeaderMap;
class ResourceRequest;
class ResourceResponse;
struct RedirectChainCacheStatus {
enum Status {
NoRedirection,
NotCachedRedirection,
CachedRedirection
};
RedirectChainCacheStatus()
: status(NoRedirection)
, endOfValidity(std::chrono::system_clock::time_point::max())
{ }
Status status;
std::chrono::system_clock::time_point endOfValidity;
};
WEBCORE_EXPORT std::chrono::microseconds computeCurrentAge(const ResourceResponse&, std::chrono::system_clock::time_point responseTimestamp);
WEBCORE_EXPORT std::chrono::microseconds computeFreshnessLifetimeForHTTPFamily(const ResourceResponse&, std::chrono::system_clock::time_point responseTimestamp);
WEBCORE_EXPORT void updateResponseHeadersAfterRevalidation(ResourceResponse&, const ResourceResponse& validatingResponse);
WEBCORE_EXPORT void updateRedirectChainStatus(RedirectChainCacheStatus&, const ResourceResponse&);
enum ReuseExpiredRedirectionOrNot { DoNotReuseExpiredRedirection, ReuseExpiredRedirection };
WEBCORE_EXPORT bool redirectChainAllowsReuse(RedirectChainCacheStatus, ReuseExpiredRedirectionOrNot);
struct CacheControlDirectives {
Optional<std::chrono::microseconds> maxAge;
Optional<std::chrono::microseconds> maxStale;
bool noCache { false };
bool noStore { false };
bool mustRevalidate { false };
};
WEBCORE_EXPORT CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap&);
WEBCORE_EXPORT Vector<std::pair<String, String>> collectVaryingRequestHeaders(const ResourceRequest&, const ResourceResponse&, SessionID = SessionID::defaultSessionID());
WEBCORE_EXPORT bool verifyVaryingRequestHeaders(const Vector<std::pair<String, String>>& varyingRequestHeaders, const ResourceRequest&, SessionID = SessionID::defaultSessionID());
}
#endif