-/* $Id: client.c,v 1.3 2007-05-10 11:46:09 adam Exp $
+/* $Id: client.c,v 1.8 2007-06-06 11:56:35 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
for (ndb = 0; sdb->database->databases[ndb]; ndb++)
databaselist[ndb] = sdb->database->databases[ndb];
- if (!(piggyback = session_setting_oneval(sdb, PZ_PIGGYBACK)) || *piggyback == '1')
+ if (!(piggyback = session_setting_oneval(sdb, PZ_PIGGYBACK))
+ || *piggyback == '1')
{
if ((recsyn = session_setting_oneval(sdb, PZ_REQUESTSYNTAX)))
{
Z_Records *recs = r->records;
if (recs->which == Z_Records_NSD)
{
- yaz_log(YLOG_WARN,
- "Search response: Non-surrogate diagnostic %s",
- cl->database->database->url);
+ yaz_log(YLOG_WARN,
+ "Search response: Non-surrogate diagnostic %s (%d)",
+ cl->database->database->url,
+ *recs->u.nonSurrogateDiagnostic->condition);
cl->diagnostic = *recs->u.nonSurrogateDiagnostic->condition;
cl->state = Client_Error;
}
struct session_database *sdb = client_get_database(cl);
char *auth = session_setting_oneval(sdb, PZ_AUTHENTICATION);
- if (auth)
+ if (*auth)
{
+ struct connection *co = client_get_connection(cl);
+ struct session *se = client_get_session(cl);
Z_IdAuthentication *idAuth = odr_malloc(global_parameters.odr_out,
sizeof(*idAuth));
idAuth->which = Z_IdAuthentication_open;
idAuth->u.open = auth;
req->idAuthentication = idAuth;
+ connection_set_authentication(co, nmem_strdup(se->session_nmem, auth));
}
}
+static void init_zproxy(struct client *cl, Z_InitRequest *req)
+{
+ struct session_database *sdb = client_get_database(cl);
+ char *ztarget = sdb->database->url;
+ //char *ztarget = sdb->url;
+ char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY);
+
+ if (*zproxy)
+#if YAZ_VERSIONL >= 0x020163
+ yaz_oi_set_string_oid(&req->otherInfo,
+ global_parameters.odr_out,
+ yaz_oid_userinfo_proxy,
+ 1, ztarget);
+#else
+ yaz_oi_set_string_oidval(&req->otherInfo,
+ global_parameters.odr_out, VAL_PROXY,
+ 1, ztarget);
+#endif
+}
+
+
static void client_init_request(struct client *cl)
{
Z_APDU *a = zget_APDU(global_parameters.odr_out, Z_APDU_initRequest);
ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_3);
init_authentication(cl, a->u.initRequest);
+ init_zproxy(cl, a->u.initRequest);
+
- /* add virtual host if tunneling through Z39.50 proxy */
-
- if (0 < strlen(global_parameters.zproxy_override)
- && 0 < strlen(client_get_database(cl)->database->url))
- {
-#if YAZ_VERSIONL >= 0x020163
- yaz_oi_set_string_oid(&a->u.initRequest->otherInfo,
- global_parameters.odr_out,
- yaz_oid_userinfo_proxy,
- 1, client_get_database(cl)->database->url);
-#else
- yaz_oi_set_string_oidval(&a->u.initRequest->otherInfo,
- global_parameters.odr_out, VAL_PROXY,
- 1, client_get_database(cl->database)->url);
-#endif
- }
if (send_apdu(cl, a) >= 0)
client_set_state(cl, Client_Initializing);
}
wrbuf_rewind(se->wrbuf);
ccl_pquery(se->wrbuf, cn);
- wrbuf_putc(se->wrbuf, '\0');
- if (cl->pquery)
- xfree(cl->pquery);
- cl->pquery = xstrdup(wrbuf_buf(se->wrbuf));
+ xfree(cl->pquery);
+ cl->pquery = xstrdup(wrbuf_cstr(se->wrbuf));
if (!se->relevance)
{