From: Adam Dickmeiss Date: Tue, 2 Jul 2013 09:03:08 +0000 (+0200) Subject: http_client: disables HTTP redirect by default X-Git-Tag: v1.3.59~26 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;ds=sidebyside;h=1751c7afd96e1984f5710284cdcb245a93d9ce6c;p=metaproxy-moved-to-github.git http_client: disables HTTP redirect by default It can be configured with max-redirects in configuration. --- diff --git a/src/filter_http_client.cpp b/src/filter_http_client.cpp index 6cb9633..6a268c3 100644 --- a/src/filter_http_client.cpp +++ b/src/filter_http_client.cpp @@ -50,10 +50,17 @@ namespace metaproxy_1 { void proxy(mp::Package &package); std::string proxy_host; std::string default_host; + int max_redirects; + Rep(); }; } } +yf::HTTPClient::Rep::Rep() +{ + max_redirects = -0; +} + yf::HTTPClient::HTTPClient() : m_p(new Rep) { } @@ -80,6 +87,8 @@ void yf::HTTPClient::Rep::proxy(mp::Package &package) if (*http_proxy) yaz_url_set_proxy(yaz_url, http_proxy); + yaz_url_set_max_redirects(yaz_url, max_redirects); + std::string uri; if (hreq->path[0] == '/') { @@ -131,6 +140,10 @@ void mp::filter::HTTPClient::configure(const xmlNode * ptr, bool test_only, { m_p->proxy_host = mp::xml::get_text(ptr); } + else if (!strcmp((const char *) ptr->name, "max-redirects")) + { + m_p->max_redirects = mp::xml::get_int(ptr, 0); + } else if (!strcmp((const char *) ptr->name, "default-host")) { m_p->default_host = mp::xml::get_text(ptr); diff --git a/xml/schema/filter_http_client.rnc b/xml/schema/filter_http_client.rnc index 9335290..070992a 100644 --- a/xml/schema/filter_http_client.rnc +++ b/xml/schema/filter_http_client.rnc @@ -7,5 +7,6 @@ filter_http_client = attribute id { xsd:NCName }?, attribute name { xsd:NCName }?, element mp:default-host { xsd:string }?, + element mp:max-redirects { xsd:integer }?, element mp:proxy { xsd:string }?