77 BESDEBUG(MODULE, prolog <<
"BEGIN url: " << source_url->str() << endl);
78 BESDEBUG(MODULE_DUMPER, prolog <<
"dump: " << endl <<
dump() << endl);
81 std::lock_guard<std::mutex> lock_me(d_cache_lock_mutex);
84 BESDEBUG(MODULE, prolog <<
"CACHE IS DISABLED." << endl);
85 return shared_ptr<EffectiveUrl>(
new EffectiveUrl(source_url));
89 if (source_url->str().find(HTTP_PROTOCOL) != 0 && source_url->str().find(HTTPS_PROTOCOL) != 0) {
90 BESDEBUG(MODULE, prolog <<
"END Not an HTTP request, SKIPPING." << endl);
91 return shared_ptr<EffectiveUrl>(
new EffectiveUrl(source_url));
98 size_t match_length = 0;
99 match_length = d_skip_regex->match(source_url->str().c_str(), (
int) source_url->str().size());
100 if (match_length == source_url->str().size()) {
101 BESDEBUG(MODULE, prolog <<
"END Candidate url matches the "
102 "no_redirects_regex_pattern [" << d_skip_regex->pattern() <<
103 "][match_length=" << match_length <<
"] SKIPPING." << endl);
104 return shared_ptr<EffectiveUrl>(
new EffectiveUrl(source_url));
106 BESDEBUG(MODULE, prolog <<
"Candidate url: '" << source_url->str()
107 <<
"' does NOT match the skip_regex pattern [" << d_skip_regex->pattern() <<
"]"
110 BESDEBUG(MODULE, prolog <<
"The cache_effective_urls_skip_regex() was NOT SET " << endl);
113 shared_ptr<EffectiveUrl> effective_url = get_cached_eurl(source_url->str());
114 bool retrieve_and_cache = !effective_url || effective_url->is_expired();
117 if (retrieve_and_cache) {
118 BESDEBUG(MODULE, prolog <<
"Acquiring effective URL for " << source_url->str() << endl);
120 BES_STOPWATCH_START(MODULE_TIMER, prolog +
"Retrieve and cache effective url for source url: " + source_url->str());
123 effective_url = curl::get_redirect_url(source_url);
126 string err_msg = prolog +
"Hyrax encountered a Service Chaining Error while "
127 "attempting to retrieve a redirect URL.\n"
128 "This is most likely problem with TEA, the AWS URL "
134 BESDEBUG(MODULE, prolog <<
" source_url: " << source_url->str() <<
" ("
135 << (source_url->is_trusted() ?
"" :
"NOT ") <<
"trusted)" << endl);
136 BESDEBUG(MODULE, prolog <<
"effective_url: " << effective_url->dump() <<
" ("
137 << (source_url->is_trusted() ?
"" :
"NOT ") <<
"trusted)" << endl);
139 d_effective_urls[source_url->str()] = effective_url;
141 BESDEBUG(MODULE, prolog <<
"Updated record for " << source_url->str() <<
" cache size: "
142 << d_effective_urls.size() << endl);
150 effective_url = make_shared<EffectiveUrl>(effective_url);
154 effective_url = make_shared<EffectiveUrl>(effective_url, source_url->is_trusted());
157 BESDEBUG(MODULE_DUMPER, prolog <<
"dump: " << endl <<
dump() << endl);
158 BESDEBUG(MODULE, prolog <<
"END" << endl);
160 return effective_url;
193 strm << BESIndent::LMarg << prolog <<
"(this: " << (
void *)
this <<
")" << endl;
195 strm << BESIndent::LMarg <<
"d_skip_regex: " << (d_skip_regex ? d_skip_regex->pattern() :
"WAS NOT SET") << endl;
196 if (!d_effective_urls.empty()) {
197 strm << BESIndent::LMarg <<
"effective url list:" << endl;
199 for (
auto const &i: d_effective_urls) {
200 strm << BESIndent::LMarg << i.first <<
" --> " << i.second->str();
202 BESIndent::UnIndent();
204 strm << BESIndent::LMarg <<
"effective url list: EMPTY" << endl;
206 BESIndent::UnIndent();