From 1792cb2b795187eb86cbd9780e0d7b71ea3a270c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 11 Jun 2013 13:47:22 +0200 Subject: [PATCH] http_client: honor X-Metaproxy-Proxy MP-451 And require YAZ 4.2.59 because it has z_HTTP_header_remove. --- configure.ac | 4 ++-- debian/control | 2 +- metaproxy.spec | 2 +- src/filter_http_client.cpp | 20 +++++++++----------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 6f870a0..ada1153 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]], [[ -#if YAZ_VERSIONL < 0x40232 +#if YAZ_VERSIONL < 0x4023B #error too old #endif ]])], diff --git a/debian/control b/debian/control index be118e0..1756ecb 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Standards-Version: 3.6.2 Maintainer: Adam Dickmeiss 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, diff --git a/metaproxy.spec b/metaproxy.spec index 5a7bf29..80e42a3 100644 --- a/metaproxy.spec +++ b/metaproxy.spec @@ -9,7 +9,7 @@ Vendor: Index Data ApS 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 diff --git a/src/filter_http_client.cpp b/src/filter_http_client.cpp index 74a1aa8..6cb9633 100644 --- a/src/filter_http_client.cpp +++ b/src/filter_http_client.cpp @@ -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 -- 1.7.10.4