Fix vhost problem YAZ-654
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 23 Apr 2013 12:54:21 +0000 (14:54 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 23 Apr 2013 12:54:21 +0000 (14:54 +0200)
Problem was that COMSTACK type was determined by vhost when
proxy was given. Proxy overrides host, except for the determination
of protocol (oid_proto).

src/comstack.c

index 451730a..f52abde 100644 (file)
@@ -126,11 +126,6 @@ static int cs_parse_host(const char *uri, const char **host,
             (*connect_host)[len] = '\0';
             uri = cp + 1;
         }
             (*connect_host)[len] = '\0';
             uri = cp + 1;
         }
-        else
-        {
-            *connect_host = xstrdup(uri);
-            uri += strlen(uri); /* set to "" */
-        }
 #ifdef WIN32
         return 0;
 #else
 #ifdef WIN32
         return 0;
 #else
@@ -195,7 +190,22 @@ COMSTACK cs_create_host_proxy(const char *vhost, int blocking, void **vp,
     char *connect_host = 0;
 
     if (!cs_parse_host(vhost, &host, &t, &proto, &connect_host))
     char *connect_host = 0;
 
     if (!cs_parse_host(vhost, &host, &t, &proto, &connect_host))
+    {
+        xfree(connect_host);
         return 0;
         return 0;
+    }
+
+    if (proxy_host)
+    {
+        enum oid_proto proto1;
+
+        xfree(connect_host);
+        if (!cs_parse_host(proxy_host, &host, &t, &proto1, &connect_host))
+        {
+            xfree(connect_host);
+            return 0;
+        }
+    }
 
     if (t == tcpip_type)
     {
 
     if (t == tcpip_type)
     {
@@ -207,8 +217,6 @@ COMSTACK cs_create_host_proxy(const char *vhost, int blocking, void **vp,
     }
     if (cs)
     {
     }
     if (cs)
     {
-        if (proxy_host)
-            host = proxy_host;
         if (!(*vp = cs_straddr(cs, connect_host ? connect_host : host)))
         {
             cs_close (cs);
         if (!(*vp = cs_straddr(cs, connect_host ? connect_host : host)))
         {
             cs_close (cs);