1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HTTP_CACHE_REQUEST_H 17 #define HTTP_CACHE_REQUEST_H 18 19 #include <cstring> 20 #include <iostream> 21 #include <map> 22 23 #include "http_time.h" 24 25 namespace OHOS::NetStack::Http { 26 class HttpCacheRequest { 27 public: 28 HttpCacheRequest(); 29 30 ~HttpCacheRequest(); 31 32 void ParseRequestHeader(const std::map<std::string, std::string> &requestHeader); 33 34 void SetRequestTime(const std::string &requestTime); 35 36 [[nodiscard]] time_t GetIfModifiedSince() const; 37 38 [[nodiscard]] time_t GetRequestTime() const; 39 40 [[nodiscard]] time_t GetMaxAgeSeconds() const; 41 42 [[nodiscard]] time_t GetMaxStaleSeconds() const; 43 44 [[nodiscard]] time_t GetMinFreshSeconds() const; 45 46 [[nodiscard]] bool IsNoCache() const; 47 48 [[nodiscard]] bool IsNoStore() const; 49 50 [[nodiscard]] bool IsNoTransform() const; 51 52 [[nodiscard]] bool IsOnlyIfCached() const; 53 54 [[nodiscard]] std::string GetIfNoneMatch() const; 55 56 private: 57 void ParseCacheControl(const std::string &cacheControl); 58 59 private: 60 std::string requestTime_; 61 std::string ifModifiedSince_; 62 std::string ifNoneMatch_; 63 64 std::string maxAge_; 65 std::string maxStale_; 66 std::string minFresh_; 67 68 bool noCache_ = false; 69 bool noStore_ = false; 70 bool noTransform_ = false; 71 bool onlyIfCached_ = false; 72 }; 73 } // namespace OHOS::NetStack::Http 74 #endif // HTTP_CACHE_REQUEST_H 75