+// Read (and remove) the X-Metaproxy-SkipLink headers
+void yf::HttpRewrite::Phase::read_skip_headers(Z_HTTP_Request *hreq,
+ std::list<boost::regex> &skip_list )
+{
+ std::string url(hreq->path);
+ if ( url.substr(0,7) != "http://" )
+ { // path was relative, as it usually is
+ const char *host = z_HTTP_header_lookup(hreq->headers, "Host");
+ if (host)
+ url = "http://" + std::string(host) + hreq->path ;
+ }
+
+ while ( const char *hv = z_HTTP_header_remove( &(hreq->headers),
+ "X-Metaproxy-SkipLink") )
+ {
+ yaz_log(YLOG_LOG,"Found SkipLink '%s'", hv );
+ const char *p = strchr(hv,' ');
+ if (!p)
+ continue; // should not happen
+ std::string page(hv,p);
+ std::string link(p+1);
+ boost::regex pagere(page);
+ if ( boost::regex_search(url, pagere) )
+ {
+ yaz_log(YLOG_LOG,"SkipLink '%s' matches URL %s",
+ page.c_str(), url.c_str() );
+ boost::regex linkre(link);
+ skip_list.push_back(linkre);
+ }
+ else
+ {
+ yaz_log(YLOG_LOG,"SkipLink ignored, '%s' does not match '%s'",
+ url.c_str(), page.c_str() );
+ }
+ }
+}
+
+