From: Adam Dickmeiss Date: Fri, 10 Jan 2014 13:00:25 +0000 (+0100) Subject: ZOOM C uses yaz_check_location X-Git-Tag: v5.0.11~8 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=3bfb3813869cfa6d6e199bf7a24ebd8e300054be ZOOM C uses yaz_check_location --- diff --git a/src/zoom-c.c b/src/zoom-c.c index b162b6d..331f544 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -1555,26 +1555,16 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) { /* since redirect may change host we just reconnect. A smarter implementation might check whether it's the same server */ - if (*location != '/') + + int host_change = 0; + location = yaz_check_location(c->odr_in, c->host_port, + location, &host_change); + if (host_change) { - /* full header */ - do_connect_host(c, location); - send_HTTP_redirect(c, location); - } - else - { /* relative header - same host */ - char *args = 0; - char *nlocation = odr_malloc(c->odr_in, strlen(location) - + strlen(c->host_port) + 3); - strcpy(nlocation, c->host_port); - cs_get_host_args(nlocation, (const char **) &args); - if (!args || !*args) - args = nlocation + strlen(nlocation); - else - args--; - strcpy(args, location); - send_HTTP_redirect(c, nlocation); + if (do_connect_host(c, location) == zoom_complete) + return; /* connect failed.. */ } + send_HTTP_redirect(c, location); return; } }