Use CONNECT for SSL backends and for Z39.50 thru HTTP proxy YAZ-825
[yaz-moved-to-github.git] / client / client.c
index 898234b..3f79e7a 100644 (file)
@@ -127,6 +127,7 @@ static char ccl_fields[512] = "default.bib";
 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;
@@ -349,7 +350,7 @@ static void send_Z3950_initRequest(const char* type_and_host)
 
     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);
@@ -545,7 +546,7 @@ static void render_diag(Z_DiagnosticFormat *diag)
             Z_DefaultDiagFormat *dd = ds->u.defaultDiagRec;
             /* ### should check `dd->diagnosticSetId' */
             printf("code=" ODR_INT_PRINTF " (%s)", *dd->condition,
-                   diagbib1_str(*dd->condition));
+                   diagbib1_str((int) *dd->condition));
             /* Both types of addinfo are the same, so use type-pun */
             if (dd->u.v2Addinfo != 0)
                 printf(",\n\taddinfo='%s'", dd->u.v2Addinfo);
@@ -703,7 +704,7 @@ static int session_connect_base(const char *arg, const char **basep)
     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);
@@ -1203,7 +1204,7 @@ static void display_diagrecs(Z_DiagRec **pp, int num)
                 printf("Unknown diagset: %s\n", diag_name);
         }
         printf("    [" ODR_INT_PRINTF "] %s",
-               *r->condition, diagbib1_str(*r->condition));
+               *r->condition, diagbib1_str((int) *r->condition));
         switch (r->which)
         {
         case Z_DefaultDiagFormat_v2Addinfo:
@@ -1320,7 +1321,7 @@ static int send_srw_host_path(Z_SRW_PDU *sr, const char *host_port,
     const char *charset = negotiationCharset;
     Z_GDU *gdu;
 
-    gdu = z_get_HTTP_Request_host_path(out, host_port, path);
+    gdu = z_get_HTTP_Request_uri(out, host_port, path, proxy_mode);
 
     if (auth)
     {
@@ -1363,8 +1364,7 @@ static int send_srw_host_path(Z_SRW_PDU *sr, const char *host_port,
 
 static int send_srw(Z_SRW_PDU *sr)
 {
-    char *path = yaz_encode_sru_dbpath_odr(out, databaseNames[0]);
-    return send_srw_host_path(sr, wrbuf_cstr(cur_host), path);
+    return send_srw_host_path(sr, wrbuf_cstr(cur_host), databaseNames[0]);
 }
 
 static int send_SRW_redirect(const char *uri)
@@ -3478,7 +3478,7 @@ static void process_Z3950_scanResponse(Z_ScanResponse *res)
         num_entries = res->entries->num_entries;
     for (i = 0; i < num_entries; i++)
     {
-        int pos_term = res->positionOfTerm ? *res->positionOfTerm : -1;
+        Odr_int pos_term = res->positionOfTerm ? *res->positionOfTerm : -1;
         if (entries[i]->which == Z_Entry_termInfo)
         {
             printf("%c ", i + 1 == pos_term ? '*' : ' ');