</filter>
<filter type="http_client">
<default-host>http://localhost:9999</default-host>
+ <x-forwarded-for>true</x-forwarded-for>
</filter>
<filter type="bounce"/>
</route>
std::string proxy_host;
std::string default_host;
int max_redirects;
+ bool x_forwarded_for;
Rep();
};
}
yf::HTTPClient::Rep::Rep()
{
- max_redirects = -0;
+ max_redirects = 0;
+ x_forwarded_for = false;
}
yf::HTTPClient::HTTPClient() : m_p(new Rep)
yaz_url_set_max_redirects(yaz_url, max_redirects);
+ if (x_forwarded_for)
+ {
+ std::string peer_name2 = package.origin().get_address();
+ const char *peer_name1 =
+ z_HTTP_header_lookup(hreq->headers, "X-Forwarded-For");
+ std::string pcomb;
+ if (peer_name1)
+ {
+ pcomb.append(peer_name1);
+ pcomb.append(", ");
+ }
+ pcomb.append(peer_name2);
+ z_HTTP_header_set(o, &hreq->headers, "X-Forwarded-For",
+ pcomb.c_str());
+ }
std::string uri;
if (hreq->path[0] == '/')
{
" in http_client filter");
}
}
+ else if (!strcmp((const char *) ptr->name, "x-forwarded-for"))
+ {
+ m_p->x_forwarded_for = mp::xml::get_bool(ptr, 0);
+ }
else
{
throw mp::filter::FilterException
attribute name { xsd:NCName }?,
element mp:default-host { xsd:string }?,
element mp:max-redirects { xsd:integer }?,
- element mp:proxy { xsd:string }?
+ element mp:proxy { xsd:string }?,
+ element mp:x-forwarded-for { xsd:boolean }?