X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-c.c;h=56d631f435715028e351fc385698e95d57a87e6e;hp=dd1698cbb3169c8d427d743b33b7a7a82abd5576;hb=3d536728dae01844f9a2b89337eb3b3fdb759382;hpb=e137416de024bcc37cc35ecae1ce2079f188ac41 diff --git a/src/zoom-c.c b/src/zoom-c.c index dd1698c..56d631f 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -793,6 +793,29 @@ ZOOM_API(int) static zoom_ret do_write(ZOOM_connection c); +ZOOM_API(void) ZOOM_resultset_release(ZOOM_resultset r) +{ +#if ZOOM_RESULT_LISTS +#else + if (r->connection) + { + /* remove ourselves from the resultsets in connection */ + ZOOM_resultset *rp = &r->connection->resultsets; + while (1) + { + assert(*rp); /* we must be in this list!! */ + if (*rp == r) + { /* OK, we're here - take us out of it */ + *rp = (*rp)->next; + break; + } + rp = &(*rp)->next; + } + r->connection = 0; + } +#endif +} + ZOOM_API(void) ZOOM_connection_destroy(ZOOM_connection c) { @@ -1102,24 +1125,7 @@ static void resultset_destroy(ZOOM_resultset r) yaz_log(log_details, "%p ZOOM_connection resultset_destroy: Deleting resultset (%p) ", r->connection, r); ZOOM_resultset_cache_reset(r); -#if ZOOM_RESULT_LISTS -#else - if (r->connection) - { - /* remove ourselves from the resultsets in connection */ - ZOOM_resultset *rp = &r->connection->resultsets; - while (1) - { - assert(*rp); /* we must be in this list!! */ - if (*rp == r) - { /* OK, we're here - take us out of it */ - *rp = (*rp)->next; - break; - } - rp = &(*rp)->next; - } - } -#endif + ZOOM_resultset_release(r); ZOOM_query_destroy(r->query); ZOOM_options_destroy(r->options); odr_destroy(r->odr); @@ -4235,17 +4241,38 @@ static zoom_ret send_SRW_redirect(ZOOM_connection c, const char *uri, { struct Z_HTTP_Header *h; Z_GDU *gdu = get_HTTP_Request_url(c->odr_out, uri); + char *combined_cookies; + int combined_cookies_len = 0; gdu->u.HTTP_Request->method = odr_strdup(c->odr_out, "GET"); z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers, "Accept", "text/xml"); - + for (h = cookie_hres->headers; h; h = h->next) { if (!strcmp(h->name, "Set-Cookie")) - z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers, - "Cookie", h->value); + { + 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(c->odr_out, &gdu->u.HTTP_Request->headers, + "Cookie", combined_cookies); + xfree(combined_cookies); + } + if (c->user && c->password) { z_HTTP_header_add_basic_auth(c->odr_out, &gdu->u.HTTP_Request->headers,