X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-c.c;h=56d631f435715028e351fc385698e95d57a87e6e;hb=eb68779c8a1e2ea059b5cf1a790e5047e3190bf2;hp=a2a02352347bb05283c285fa3eb0452a558549bf;hpb=bb6807db66cc4aa2a9ceb1a5ae7eb79f53716614;p=yaz-moved-to-github.git diff --git a/src/zoom-c.c b/src/zoom-c.c index a2a0235..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, @@ -4350,18 +4377,34 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) do_close(c); } if (cret == zoom_complete) - ZOOM_connection_remove_task(c); - if (!strcmp(hres->version, "1.0")) { - /* HTTP 1.0: only if Keep-Alive we stay alive.. */ - if (!connection_head || strcmp(connection_head, "Keep-Alive")) - do_close(c); + yaz_log(YLOG_LOG, "removing tasks in handle_http"); + ZOOM_connection_remove_task(c); } - else { - /* HTTP 1.1: only if no close we stay alive .. */ - if (connection_head && !strcmp(connection_head, "close")) + int must_close = 0; + if (!strcmp(hres->version, "1.0")) + { + /* HTTP 1.0: only if Keep-Alive we stay alive.. */ + if (!connection_head || strcmp(connection_head, "Keep-Alive")) + must_close = 1; + } + else + { + /* HTTP 1.1: only if no close we stay alive.. */ + if (connection_head && !strcmp(connection_head, "close")) + must_close = 1; + } + if (must_close) + { do_close(c); + if (c->tasks) + { + c->tasks->running = 0; + ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT); + c->reconnect_ok = 0; + } + } } } #endif