http_client: honor X-Metaproxy-Proxy MP-451
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 11 Jun 2013 11:47:22 +0000 (13:47 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 11 Jun 2013 11:47:22 +0000 (13:47 +0200)
And require YAZ 4.2.59 because it has z_HTTP_header_remove.

configure.ac
debian/control
metaproxy.spec
src/filter_http_client.cpp

index 6f870a0..ada1153 100644 (file)
@@ -45,11 +45,11 @@ if test -z "$YAZPPLIB"; then
     AC_MSG_ERROR([YAZ++ development libraries missing])
 fi
 CPPFLAGS="$YAZPPINC $CPPFLAGS"
-AC_MSG_CHECKING([if YAZ is version 4.2.50 or later])
+AC_MSG_CHECKING([if YAZ is version 4.2.59 or later])
 AC_COMPILE_IFELSE(
         [AC_LANG_PROGRAM([[#include <yaz/yaz-version.h>]],
                          [[
-#if YAZ_VERSIONL < 0x40232
+#if YAZ_VERSIONL < 0x4023B
 #error too old
 #endif
 ]])],
index be118e0..1756ecb 100644 (file)
@@ -4,7 +4,7 @@ Standards-Version: 3.6.2
 Maintainer: Adam Dickmeiss <adam@indexdata.dk>
 Priority: extra
 Build-Depends: debhelper (>= 5),
-       libyaz4-dev (>= 4.2.50),
+       libyaz4-dev (>= 4.2.59),
        libyazpp5-dev (>= 1.4.1),
        libxslt1-dev,
        libboost-dev,
index 5a7bf29..80e42a3 100644 (file)
@@ -9,7 +9,7 @@ Vendor: Index Data ApS <info@indexdata.dk>
 Source: metaproxy-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-root
 Prefix: %{_prefix} /etc/metaproxy
-BuildRequires: pkgconfig, libyaz4-devel >= 4.2.50, libyazpp5-devel >= 1.4.1
+BuildRequires: pkgconfig, libyaz4-devel >= 4.2.59, libyazpp5-devel >= 1.4.1
 BuildRequires: libxslt-devel, boost-devel
 Conflicts: cf-engine <= 2.12.5
 Packager: Adam Dickmeiss <adam@indexdata.dk>
index 74a1aa8..6cb9633 100644 (file)
@@ -71,11 +71,16 @@ void yf::HTTPClient::Rep::proxy(mp::Package &package)
         Z_GDU *res_gdu = 0;
         mp::odr o;
         yaz_url_t yaz_url = yaz_url_create();
-        std::string uri;
+        const char *http_proxy =
+            z_HTTP_header_remove(&hreq->headers, "X-Metaproxy-Proxy");
+
+        if (!http_proxy)
+            http_proxy = proxy_host.c_str();
 
-        if (proxy_host.length())
-            yaz_url_set_proxy(yaz_url, proxy_host.c_str());
+        if (*http_proxy)
+            yaz_url_set_proxy(yaz_url, http_proxy);
 
+        std::string uri;
         if (hreq->path[0] == '/')
         {
             if (default_host.length())
@@ -92,14 +97,7 @@ void yf::HTTPClient::Rep::proxy(mp::Package &package)
         if (http_response)
         {
             res_gdu = o.create_HTTP_Response(package.session(), hreq, 200);
-            Z_HTTP_Header **hp = &http_response->headers;
-            while (*hp)
-            {
-                if (!yaz_matchstr((*hp)->name, "Transfer-Encoding"))
-                    *hp = (*hp)->next;
-                else
-                    hp = &(*hp)->next;
-            }
+            z_HTTP_header_remove(&http_response->headers, "Transfer-Encoding");
             res_gdu->u.HTTP_Response = http_response;
         }
         else