return p;
}
+Z_GDU *z_get_HTTP_Request_uri(ODR odr, const char *uri, const char *args,
+ int use_full_uri)
+{
+ Z_GDU *p = z_get_HTTP_Request(odr);
+ const char *cp0 = strstr(uri, "://");
+ const char *cp1 = 0;
+ if (cp0)
+ cp0 = cp0+3;
+ else
+ cp0 = uri;
+
+ cp1 = strchr(cp0, '/');
+ if (!cp1)
+ cp1 = cp0+strlen(cp0);
+
+ if (cp0 && cp1)
+ {
+ char *h = (char*) odr_malloc(odr, cp1 - cp0 + 1);
+ memcpy (h, cp0, cp1 - cp0);
+ h[cp1-cp0] = '\0';
+ z_HTTP_header_add(odr, &p->u.HTTP_Request->headers,
+ "Host", h);
+ }
+
+ if (!args)
+ {
+ if (*cp1)
+ args = cp1 + 1;
+ else
+ args = "";
+ }
+ p->u.HTTP_Request->path = odr_malloc(odr, cp1 - uri + strlen(args) + 2);
+ if (use_full_uri)
+ {
+ memcpy(p->u.HTTP_Request->path, uri, cp1 - uri);
+ strcpy(p->u.HTTP_Request->path + (cp1 - uri), "/");
+ }
+ else
+ strcpy(p->u.HTTP_Request->path, "/");
+ strcat(p->u.HTTP_Request->path, args);
+ return p;
+}
Z_GDU *z_get_HTTP_Response(ODR o, int code)
{
c->options = ZOOM_options_create_with_parent(options);
c->host_port = 0;
- c->path = 0;
c->proxy = 0;
c->charset = c->lang = 0;
ZOOM_connection_remove_tasks(c);
ZOOM_connection_remove_events(c);
xfree(c->host_port);
- xfree(c->path);
xfree(c->proxy);
xfree(c->charset);
xfree(c->lang);
{
#if YAZ_HAVE_XML2
c->proto = PROTO_HTTP;
- xfree(c->path);
- if (c->proxy)
- {
- c->path = xstrdup(logical_url);
- }
- else
- {
- const char *db = 0;
-
- cs_get_host_args(logical_url, &db);
-
- c->path = xmalloc(strlen(db) * 3 + 2);
- yaz_encode_sru_dbpath_buf(c->path, db);
- }
#else
ZOOM_set_error(c, ZOOM_ERROR_UNSUPPORTED_PROTOCOL, "SRW");
ZOOM_connection_close(c);
}
#if YAZ_HAVE_XML2
-static Z_GDU *get_HTTP_Request_url(ODR odr, const char *url)
-{
- Z_GDU *p = z_get_HTTP_Request(odr);
- const char *host = url;
- const char *cp0 = strstr(host, "://");
- const char *cp1 = 0;
- if (cp0)
- cp0 = cp0+3;
- else
- cp0 = host;
-
- cp1 = strchr(cp0, '/');
- if (!cp1)
- cp1 = cp0 + strlen(cp0);
-
- if (cp0 && cp1)
- {
- char *h = (char*) odr_malloc(odr, cp1 - cp0 + 1);
- memcpy (h, cp0, cp1 - cp0);
- h[cp1-cp0] = '\0';
- z_HTTP_header_add(odr, &p->u.HTTP_Request->headers, "Host", h);
- }
- p->u.HTTP_Request->path = odr_strdup(odr, *cp1 ? cp1 : "/");
- return p;
-}
static zoom_ret send_HTTP_redirect(ZOOM_connection c, const char *uri,
Z_HTTP_Response *cookie_hres)
{
struct Z_HTTP_Header *h;
- Z_GDU *gdu = get_HTTP_Request_url(c->odr_out, uri);
char *combined_cookies = 0;
int combined_cookies_len = 0;
+ Z_GDU *gdu = z_get_HTTP_Request_uri(c->odr_out, uri, 0, c->proxy ? 1 : 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",
ZOOM_connection_set_mask(c, 0);
yaz_log(c->log_details, "%p handle_http", c);
-
+
if ((hres->code == 301 || hres->code == 302) && c->sru_mode == zoom_sru_get
&& (location = z_HTTP_header_lookup(hres->headers, "Location")))
{
do_connect_host(c, location);
send_HTTP_redirect(c, location, hres);
/* we're OK for now. Operation is not really complete */
- ret = 0;
- cret = zoom_pending;
+ return;
}
}
else
Z_GDU *gdu;
ZOOM_Event event;
const char *database = ZOOM_options_get(c->options, "databaseName");
- char *fdatabase = 0;
-
- if (database)
- fdatabase = yaz_encode_sru_dbpath_odr(c->odr_out, database);
- gdu = z_get_HTTP_Request_host_path(c->odr_out, c->host_port,
- fdatabase ? fdatabase : c->path);
+
+ gdu = z_get_HTTP_Request_uri(c->odr_out, c->host_port,
+ database,
+ c->proxy ? 1 : 0);
if (c->sru_mode == zoom_sru_get)
{