Version 4.0.11
[yaz-moved-to-github.git] / client / client.c
index 3c68c58..d1dfe50 100644 (file)
@@ -1280,6 +1280,8 @@ static int send_SRW_redirect(const char *uri, Z_HTTP_Response *cookie_hres)
     const char *username = 0;
     const char *password = 0;
     struct Z_HTTP_Header *h;
+    char *combined_cookies;
+    int combined_cookies_len = 0;
     Z_GDU *gdu = get_HTTP_Request_url(out, uri);
 
     gdu->u.HTTP_Request->method = odr_strdup(out, "GET");
@@ -1288,9 +1290,24 @@ static int send_SRW_redirect(const char *uri, Z_HTTP_Response *cookie_hres)
     
     for (h = cookie_hres->headers; h; h = h->next)
     {
-        if (!strcmp(h->name, "Set-Cookie"))
-            z_HTTP_header_add(out, &gdu->u.HTTP_Request->headers,
-                              "Cookie", h->value);
+        if (!strcmp(h->name, "Set-Cookie")) {
+            char *cp;
+
+            if (!(cp = strchr(h->value, ';')))
+                cp = h->value + strlen(h->value);
+            if (cp - h->value >= 1) {
+                combined_cookies = xrealloc(combined_cookies, combined_cookies_len + cp - h->value + 3);
+                memcpy(combined_cookies+combined_cookies_len, h->value, cp - h->value);
+                combined_cookies[combined_cookies_len + cp - h->value] = '\0';
+                strcat(combined_cookies,"; ");
+                combined_cookies_len = strlen(combined_cookies);
+            }
+        }
+    }
+    if (combined_cookies_len)
+    {
+        z_HTTP_header_add(out, &gdu->u.HTTP_Request->headers, "Cookie", combined_cookies);
+        xfree(combined_cookies);
     }
 
     if (auth)
@@ -2850,6 +2867,7 @@ static int parse_show_args(const char *arg_c, char *setstring,
                            Odr_int *start, Odr_int *number)
 {
     char *end_ptr;
+    Odr_int start_position;
 
     if (setnumber >= 0)
         sprintf(setstring, "%d", setnumber);
@@ -2861,8 +2879,11 @@ static int parse_show_args(const char *arg_c, char *setstring,
         *number = last_hit_count;
         *start = 1;
     }
-    *start = odr_strtol(arg_c, &end_ptr, 10);
-    if (end_ptr == arg_c || *end_ptr == '\0')
+    start_position = odr_strtol(arg_c, &end_ptr, 10);
+    if (end_ptr == arg_c)
+        return 1;
+    *start = start_position;
+    if (*end_ptr == '\0')
         return 1;
     while (isspace(*(unsigned char *)end_ptr))
         end_ptr++;