HTTP/GET URL.
ZOOM-C reads option extraArgs. If set the value of extraArgs is appended to
SRU URI (POST/GET). Value is _raw_ URI part, such as x-id-a=v1&x-id-b=v2 .
+ZOOM-C reads option extraArgs. If set the value of extraArgs is appended to
+SRU URI (POST/GET). Value is _raw_ URI part, such as x-id-a=v1&x-id-b=v2 .
+
--- 2.1.26 2006/08/15
Fixed problem with SRU mode type (soap, get, post) for yaz-client
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: srw.h,v 1.27 2006-06-02 13:08:27 adam Exp $
+ * $Id: srw.h,v 1.28 2006-08-16 22:47:09 adam Exp $
*/
/**
* \file srw.h
char *srw_version;
char *username; /* From HTTP header or request */
char *password; /* From HTTP header or request */
+ char *extra_args; /* For SRU GET/POST only */
} Z_SRW_PDU;
YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
YAZ_EXPORT int yaz_ucp_codec(ODR o, void * pptr,
Z_SRW_PDU **handler_data,
void *client_data, const char *ns);
+YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o);
YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
YAZ_EXPORT Z_SRW_extra_record *yaz_srw_get_extra_record(ODR o);
/*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.46 2006-07-06 10:17:54 adam Exp $
+ * $Id: srw.c,v 1.47 2006-08-16 22:47:10 adam Exp $
*/
/**
* \file srw.c
return 0;
}
+Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o)
+{
+ Z_SRW_PDU *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(*p));
+ p->srw_version = odr_strdup(o, "1.1");
+ p->username = 0;
+ p->password = 0;
+ p->extra_args = 0;
+ return p;
+}
+
int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
void *client_data, const char *ns)
{
if (method->type != XML_ELEMENT_NODE)
return -1;
- *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(**p));
- (*p)->srw_version = odr_strdup(o, "1.1");
- (*p)->username = 0;
- (*p)->password = 0;
+ *p = yaz_srw_get_core_v_1_1(o);
if (!xmlStrcmp(method->name, BAD_CAST "searchRetrieveRequest"))
{
if (method->type != XML_ELEMENT_NODE)
return -1;
- *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(**p));
- (*p)->srw_version = odr_strdup(o, "1.1");
+ *p = yaz_srw_get_core_v_1_1(o);
if (!xmlStrcmp(method->name, BAD_CAST "updateRequest"))
{
/*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: srwutil.c,v 1.45 2006-07-06 10:17:54 adam Exp $
+ * $Id: srwutil.c,v 1.46 2006-08-16 22:47:10 adam Exp $
*/
/**
* \file srwutil.c
}
}
-void yaz_array_to_uri(char **path, ODR o, char **name, char **value)
+static void yaz_array_to_uri_ex(char **path, ODR o, char **name, char **value,
+ const char *extra_args)
{
- size_t i, szp = 0, sz = 0;
+ size_t i, szp = 0, sz = extra_args ? 1+strlen(extra_args) : 1;
for(i = 0; name[i]; i++)
sz += strlen(name[i]) + 3 + strlen(value[i]) * 3;
*path = odr_malloc(o, sz);
szp += vlen;
}
}
+ if (extra_args)
+ {
+ if (i)
+ (*path)[szp++] = '&';
+ memcpy(*path + szp, extra_args, strlen(extra_args));
+ szp += strlen(extra_args);
+ }
(*path)[szp] = '\0';
}
+void yaz_array_to_uri(char **path, ODR o, char **name, char **value)
+{
+ return yaz_array_to_uri_ex(path, o, name, value, 0);
+}
+
int yaz_uri_array(const char *path, ODR o, char ***name, char ***val)
{
int no = 2;
* Look for authentication tokens in HTTP Basic parameters or in x-username/x-password
* parameters. Added by SH.
*/
-static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, char *username,
- char *password, ODR decode)
+static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq,
+ char *username, char *password, ODR decode)
{
const char *basic = z_HTTP_header_lookup(hreq->headers, "Authorization");
Z_SRW_PDU *yaz_srw_get(ODR o, int which)
{
- Z_SRW_PDU *sr = (Z_SRW_PDU *) odr_malloc(o, sizeof(*o));
-
- sr->username = 0;
- sr->password = 0;
- sr->srw_version = odr_strdup(o, "1.1");
+ Z_SRW_PDU *sr = yaz_srw_get_core_v_1_1(o);
sr->which = which;
switch(which)
{
if (yaz_get_sru_parms(srw_pdu, encode, name, value))
return -1;
- yaz_array_to_uri(&uri_args, encode, name, value);
+ yaz_array_to_uri_ex(&uri_args, encode, name, value, srw_pdu->extra_args);
hreq->method = "GET";
- path = odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 3);
+ path = odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 4
+ +(srw_pdu->extra_args ? strlen(srw_pdu->extra_args) : 0)
+ );
sprintf(path, "%s?%s", hreq->path, uri_args);
hreq->path = path;
if (yaz_get_sru_parms(srw_pdu, encode, name, value))
return -1;
- yaz_array_to_uri(&uri_args, encode, name, value);
+ yaz_array_to_uri_ex(&uri_args, encode, name, value, srw_pdu->extra_args);
hreq->method = "POST";
* Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.84 2006-08-16 14:18:59 adam Exp $
+ * $Id: zoom-c.c,v 1.85 2006-08-16 22:47:11 adam Exp $
*/
/**
* \file zoom-c.c
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_1);
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2);
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3);
-
+
/* Index Data's Z39.50 Implementor Id is 81 */
- ireq->implementationId = odr_prepend(c->odr_out,
- ZOOM_options_get(c->options, "implementationId"),
- odr_prepend(c->odr_out, "81", ireq->implementationId));
-
- ireq->implementationName = odr_prepend(c->odr_out,
- ZOOM_options_get(c->options, "implementationName"),
- odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
-
- version = odr_strdup(c->odr_out, "$Revision: 1.84 $");
+ ireq->implementationId =
+ odr_prepend(c->odr_out,
+ ZOOM_options_get(c->options, "implementationId"),
+ odr_prepend(c->odr_out, "81", ireq->implementationId));
+
+ ireq->implementationName =
+ odr_prepend(c->odr_out,
+ ZOOM_options_get(c->options, "implementationName"),
+ odr_prepend(c->odr_out, "ZOOM-C",
+ ireq->implementationName));
+
+ version = odr_strdup(c->odr_out, "$Revision: 1.85 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
- ireq->implementationVersion = odr_prepend(c->odr_out,
- ZOOM_options_get(c->options, "implementationVersion"),
- odr_prepend(c->odr_out, &version[11], ireq->implementationVersion));
-
+ ireq->implementationVersion =
+ odr_prepend(c->odr_out,
+ ZOOM_options_get(c->options, "implementationVersion"),
+ odr_prepend(c->odr_out, &version[11],
+ ireq->implementationVersion));
+
*ireq->maximumRecordSize =
ZOOM_options_get_int(c->options, "maximumRecordSize", 1024*1024);
*ireq->preferredMessageSize =
int *start, *count;
ZOOM_resultset resultset = 0;
Z_SRW_PDU *sr = 0;
- const char *recordPacking = 0;
+ const char *option_val = 0;
if (c->error) /* don't continue on error */
return zoom_complete;
sr->u.request->maximumRecords = odr_intdup(
c->odr_out, resultset->step>0 ? resultset->step : *count);
sr->u.request->recordSchema = resultset->schema;
-
- recordPacking = ZOOM_resultset_option_get(resultset, "recordPacking");
-
- if (recordPacking)
- sr->u.request->recordPacking = odr_strdup(c->odr_out, recordPacking);
+ option_val = ZOOM_resultset_option_get(resultset, "recordPacking");
+ if (option_val)
+ sr->u.request->recordPacking = odr_strdup(c->odr_out, option_val);
+
+ option_val = ZOOM_resultset_option_get(resultset, "extraArgs");
+ if (option_val)
+ sr->extra_args = odr_strdup(c->odr_out, option_val);
return send_srw(c, sr);
}
#else