870 static const char *names[2] = {
"verbose", 0 };
871 std::string values[1];
873 mp::xml::parse_attr(ptr, names, values);
875 phase.m_verbose = atoi(values[0].c_str());
877 std::map<std::string, RulePtr > rules;
878 for (ptr = ptr->children; ptr; ptr = ptr->next)
880 if (ptr->type != XML_ELEMENT_NODE)
882 else if (!strcmp((
const char *) ptr->name,
"rule"))
884 static const char *names[2] = {
"name", 0 };
885 std::string values[1];
886 values[0] =
"default";
887 mp::xml::parse_attr(ptr, names, values);
890 for (xmlNode *p = ptr->children; p; p = p->next)
892 if (p->type != XML_ELEMENT_NODE)
894 if (!strcmp((
const char *) p->name,
"rewrite"))
898 const struct _xmlAttr *attr;
899 for (attr = p->properties; attr; attr = attr->next)
901 if (!strcmp((
const char *) attr->name,
"from"))
902 from = mp::xml::get_text(attr->children);
903 else if (!strcmp((
const char *) attr->name,
"to"))
904 replace.recipe = mp::xml::get_text(attr->children);
906 throw mp::filter::FilterException
908 + std::string((
const char *) attr->name)
909 +
" in rewrite section of http_rewrite");
911 yaz_log(YLOG_LOG,
"Found rewrite rule from '%s' to '%s'",
912 from.c_str(), replace.recipe.c_str());
915 replace.parse_groups(from);
916 rule->replace_list.push_back(replace);
920 throw mp::filter::FilterException
922 + std::string((
const char *) p->name)
923 +
" in http_rewrite filter");
925 rules[values[0]] = rule;
927 else if (!strcmp((
const char *) ptr->name,
"content"))
929 static const char *names[3] =
930 {
"type",
"mime", 0 };
931 std::string values[2];
932 mp::xml::parse_attr(ptr, names, values);
933 if (values[0].empty())
935 throw mp::filter::FilterException
936 (
"Missing attribute, type for for element "
937 + std::string((
const char *) ptr->name)
938 +
" in http_rewrite filter");
943 if (!values[1].empty())
944 c.content_re.assign(values[1], boost::regex::icase);
945 c.configure(ptr->children, rules);
946 phase.content_list.push_back(c);
950 throw mp::filter::FilterException
952 + std::string((
const char *) ptr->name)
953 +
" in http_rewrite filter");