66 BESDEBUG(MODULE, prolog <<
"BEGIN" << endl);
71 auto now = std::chrono::system_clock::now();
72 auto now_secs = std::chrono::time_point_cast<std::chrono::seconds>(now);
73 BESDEBUG(MODULE, prolog <<
"now_secs: " << now_secs.time_since_epoch().count() << endl);
75 get_header(CACHE_CONTROL_HEADER_KEY, cc_hdr_val, found);
77 BESDEBUG(MODULE, prolog << CACHE_CONTROL_HEADER_KEY <<
" '" << cc_hdr_val <<
"'" << endl);
80 string max_age_key{
"max-age="};
81 size_t max_age_index = cc_hdr_val.find(max_age_key);
82 if (max_age_index != cc_hdr_val.npos) {
83 string max_age_str = cc_hdr_val.substr(max_age_index + max_age_key.size());
85 std::istringstream(max_age_str) >> msi;
86 std::chrono::seconds max_age(msi);
87 auto itime = std::chrono::system_clock::from_time_t(ingest_time());
88 auto expires_time = std::chrono::time_point_cast<std::chrono::seconds>(itime + max_age);
89 expired = now_secs > expires_time;
91 BESDEBUG(MODULE, prolog <<
"expires_time: " << expires_time.time_since_epoch().count() <<
92 " threshold: " << HTTP_URL_REFRESH_THRESHOLD << endl);
94 BESDEBUG(MODULE, prolog <<
"expired: " << (expired ?
"true" :
"false") << endl);
100 BESDEBUG(MODULE, prolog <<
"END expired: " << (expired ?
"true" :
"false") << endl);
114 auto rname_itr = d_response_header_names.rbegin();
115 auto rvalue_itr = d_response_header_values.rbegin();
116 while(!found && rname_itr != d_response_header_names.rend()){
117 string hdr_name = *rname_itr;
118 found = (lc_name == hdr_name);
132 d_response_header_names.clear();
133 d_response_header_values.clear();
135 for (
const auto &header: resp_hdrs){
136 size_t colon = header.find(
':');
137 if (colon != string::npos) {
138 string key(header.substr(0, colon));
140 string value(header.substr(colon));
141 d_response_header_names.push_back(key);
142 d_response_header_values.push_back(value);
143 BESDEBUG(MODULE, prolog <<
"Ingested header: " << key <<
": " << value <<
"(size: "
144 << d_response_header_values.size() <<
")" << endl);
147 ERROR_LOG(prolog +
"Encounter malformed response header! Missing ':' delimiter. SKIPPING");