diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-08-01 18:00:48 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-08-08 12:40:38 +0200 |
commit | f0a7c45064c3ce3f509b1c2035fcaa07ccc35a99 (patch) | |
tree | 5813cfe2fd8e72cbf06f45990351b7412146c398 /include | |
parent | 68f470fdda4e31d7704fba3e41bb2f899db39541 (diff) | |
download | qtlocation-mapboxgl-f0a7c45064c3ce3f509b1c2035fcaa07ccc35a99.tar.gz |
[core] finish must-revalidate support
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/storage/resource.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/storage/response.hpp | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp index 7e9ced8049..5d44f4869f 100644 --- a/include/mbgl/storage/resource.hpp +++ b/include/mbgl/storage/resource.hpp @@ -68,6 +68,7 @@ public: optional<Timestamp> priorModified = {}; optional<Timestamp> priorExpires = {}; optional<std::string> priorEtag = {}; + std::shared_ptr<const std::string> priorData; }; } // namespace mbgl diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index 32fe4e0c8a..711f008e83 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -27,6 +27,10 @@ public: // This is set to true for 304 Not Modified responses. bool notModified = false; + // This is set to true when the server requested that no expired resources be used by + // specifying "Cache-Control: must-revalidate". + bool mustRevalidate = false; + // The actual data of the response. Present only for non-error, non-notModified responses. std::shared_ptr<const std::string> data; @@ -37,6 +41,12 @@ public: bool isFresh() const { return expires ? *expires > util::now() : !error; } + + // Indicates whether we are allowed to use this response according to HTTP caching rules. + // It may or may not be stale. + bool isUsable() const { + return !mustRevalidate || (expires && *expires > util::now()); + } }; class Response::Error { |