static char cql_fields[512] = "/usr/local/share/yaz/etc/pqf.properties";
static char *esPackageName = 0;
static char *yazProxy = 0;
+static int proxy_mode = 0;
static int kilobytes = 64 * 1024;
static char *negotiationCharset = 0;
static int negotiationCharsetRecords = 1;
req->referenceId = set_refid(out);
- if (yazProxy && type_and_host)
+ if (proxy_mode && type_and_host)
{
yaz_oi_set_string_oid(&req->otherInfo, out, yaz_oid_userinfo_proxy,
1, type_and_host);
strncpy(type_and_host, arg, sizeof(type_and_host)-1);
type_and_host[sizeof(type_and_host)-1] = '\0';
- conn = cs_create_host_proxy(arg, 1, &add, yazProxy);
+ conn = cs_create_host2(arg, 1, &add, yazProxy, &proxy_mode);
if (!conn)
{
printf("Could not resolve address %s\n", arg);
const char *charset = negotiationCharset;
Z_GDU *gdu;
- gdu = z_get_HTTP_Request_uri(out, host_port, path, yazProxy ? 1 : 0);
+ gdu = z_get_HTTP_Request_uri(out, host_port, path, proxy_mode);
if (auth)
{
YAZ_EXPORT COMSTACK cs_create_host_proxy(const char *vhost,
int blocking, void **vp,
const char *proxy_host);
+YAZ_EXPORT COMSTACK cs_create_host2(const char *vhost, int blocking, void **vp,
+ const char *proxy_host, int *proxy_mode);
YAZ_EXPORT void cs_get_host_args(const char *type_and_host, const char **args);
YAZ_EXPORT int cs_complete_auto_head(const char *buf, int len);
YAZ_EXPORT int cs_complete_auto(const char *buf, int len);
COMSTACK cs_create_host_proxy(const char *vhost, int blocking, void **vp,
const char *proxy_host)
{
+ int proxy_mode;
+ return cs_create_host2(vhost, blocking, vp, proxy_host, &proxy_mode);
+}
+
+COMSTACK cs_create_host2(const char *vhost, int blocking, void **vp,
+ const char *proxy_host, int *proxy_mode)
+{
enum oid_proto proto = PROTO_Z3950;
const char *host = 0;
COMSTACK cs;
CS_TYPE t;
char *connect_host = 0;
+
const char *bind_host = strchr(vhost, ' ');
if (bind_host && bind_host[1])
bind_host++;
else
bind_host = 0;
+ *proxy_mode = 0;
if (!cs_parse_host(vhost, &host, &t, &proto, &connect_host))
return 0;
- if (proxy_host)
+
+ /* vhost proxy proxy method proxy-flag */
+ /* TCP+Z3950 TCP+Z3950 TCP+Z3950 1 */
+ /* TCP+Z3950 TCP+HTTP CONNECT 0 */
+ /* TCP+HTTP TCP+Z3950 TCP+HTTP 1 */
+ /* TCP+HTTP TCP+HTTP TCP+HTTP 1 */
+ /* SSL+* TCP+* CONNECT 0 */
+ /* ? SSL error */
+
+ if (proxy_host && !connect_host)
{
enum oid_proto proto1;
CS_TYPE t1;
+ const char *host1 = 0;
- xfree(connect_host);
- if (!cs_parse_host(proxy_host, &host, &t1, &proto1, &connect_host))
+ if (!cs_parse_host(proxy_host, &host1, &t1, &proto1, &connect_host))
+ return 0;
+ if (connect_host)
+ {
+ xfree(connect_host);
+ return 0;
+ }
+ if (t1 != tcpip_type)
return 0;
+
+ if (t == ssl_type || (proto == PROTO_Z3950 && proto1 == PROTO_HTTP))
+ connect_host = xstrdup(host1);
+ else
+ {
+ *proxy_mode = 1;
+ host = host1;
+ }
}
if (t == tcpip_type)
{
cs = yaz_tcpip_create3(-1, blocking, proto, connect_host ? host : 0,
- 0, bind_host);
+ 0 /* user:pass */, bind_host);
}
else if (t == ssl_type)
{
cs = yaz_ssl_create(-1, blocking, proto, connect_host ? host : 0,
- 0, bind_host);
+ 0 /* user:pass */, bind_host);
}
else
{
ODR odr_in;
ODR odr_out;
char *proxy;
+ int proxy_mode;
int max_redirects;
WRBUF w_error;
int verbose;
p->odr_in = odr_createmem(ODR_DECODE);
p->odr_out = odr_createmem(ODR_ENCODE);
p->proxy = 0;
+ p->proxy_mode = 0;
p->max_redirects = 10;
p->w_error = wrbuf_alloc();
p->verbose = 0;
extract_user_pass(p->odr_out->mem, uri, &uri_lean,
&http_user, &http_pass);
- gdu = z_get_HTTP_Request_uri(p->odr_out, uri_lean, 0, p->proxy ? 1 : 0);
+ gdu = z_get_HTTP_Request_uri(p->odr_out, uri_lean, 0, p->proxy_mode);
gdu->u.HTTP_Request->method = odr_strdup(p->odr_out, method);
yaz_cookies_request(p->cookies, p->odr_out, gdu->u.HTTP_Request);
log_warn(p);
return 0;
}
- conn = cs_create_host_proxy(uri_lean, 1, &add, p->proxy);
+ conn = cs_create_host2(uri_lean, 1, &add, p->proxy, &p->proxy_mode);
if (!conn)
{
wrbuf_printf(p->w_error, "Can not resolve URL %s", uri);
c->host_port = 0;
c->proxy = 0;
c->tproxy = 0;
+ c->proxy_mode = 0;
c->charset = c->lang = 0;
if (c->cs)
cs_close(c->cs);
- c->cs = cs_create_host_proxy(logical_url, CS_FLAGS_DNS_NO_BLOCK, &add,
- c->tproxy ? c->tproxy : c->proxy);
+ c->cs = cs_create_host2(logical_url, CS_FLAGS_DNS_NO_BLOCK, &add,
+ c->tproxy ? c->tproxy : c->proxy,
+ &c->proxy_mode);
if (c->cs && c->cs->protocol == PROTO_HTTP)
{
int len_out;
char *proxy;
char *tproxy;
+ int proxy_mode;
char *charset;
char *lang;
char *cookie_out;
const char *database = ZOOM_options_get(c->options, "databaseName");
gdu = z_get_HTTP_Request_uri(c->odr_out, c->host_port,
- database,
- c->proxy ? 1 : 0);
+ database, c->proxy_mode);
if (c->sru_mode == zoom_sru_get)
{
auth->u.open = odr_strdup(c->odr_out, c->user);
ireq->idAuthentication = auth;
}
- if (c->proxy)
+ if (c->proxy_mode)
{
yaz_oi_set_string_oid(&ireq->otherInfo, c->odr_out,
yaz_oid_userinfo_proxy, 1, c->host_port);