+ const char *http_proxy =
+ z_HTTP_header_remove(&hreq->headers, "X-Metaproxy-Proxy");
+
+ if (!http_proxy)
+ http_proxy = proxy_host.c_str();
+
+ if (*http_proxy)
+ yaz_url_set_proxy(yaz_url, http_proxy);
+
+ 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] == '/')
+ {
+ if (default_host.length())
+ uri = default_host + hreq->path;
+ }
+ else
+ uri = hreq->path;