* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: soap.h,v 1.2 2003-02-14 18:49:23 adam Exp $
+ * $Id: soap.h,v 1.3 2003-03-11 11:09:17 adam Exp $
*/
#ifndef YAZ_SOAP_H
YAZ_EXPORT int z_soap_codec(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers);
+YAZ_EXPORT int z_soap_codec_enc(ODR o, Z_SOAP **pp,
+ char **content_buf, int *content_len,
+ Z_SOAP_Handler *handlers, const char *encoding);
#endif
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.147 2003-02-23 20:39:31 adam Exp $
+ * $Id: seshigh.c,v 1.148 2003-03-11 11:09:17 adam Exp $
*/
/*
if (!(anew = (association *)xmalloc(sizeof(*anew))))
return 0;
anew->init = 0;
+ anew->version = 0;
anew->client_chan = channel;
anew->client_link = link;
anew->cs_get_mask = 0;
static int srw_bend_init(association *assoc)
{
+ const char *encoding = "UTF-8";
+ Z_External *ce;
bend_initresult *binitres;
statserv_options_block *cb = statserv_getcontrol();
assoc->maximumRecordSize = 3000000;
assoc->preferredMessageSize = 3000000;
-
+#if 1
+ ce = yaz_set_proposal_charneg(assoc->decode, &encoding, 1, 0, 0, 1);
+ assoc->init->charneg_request = ce->u.charNeg3;
+#endif
if (!(binitres = (*cb->bend_init)(assoc->init)))
{
yaz_log(LOG_WARN, "Bad response from backend.");
Z_SOAP *soap_package = 0;
int ret = -1;
int http_code = 500;
+ const char *charset_p = 0;
+ char *charset = 0;
static Z_SOAP_Handler soap_handlers[2] = {
#if HAVE_XML2
#endif
{0, 0, 0}
};
+ if ((charset_p = strstr(content_type, "; charset=")))
+ {
+ int i = 0;
+ charset_p += 10;
+ while (i < 20 && charset_p[i] &&
+ !strchr("; \n\r", charset_p[i]))
+ i++;
+ charset = odr_malloc(assoc->encode, i+1);
+ memcpy(charset, charset_p, i);
+ charset[i] = '\0';
+ yaz_log(LOG_LOG, "SOAP encoding %s", charset);
+ }
ret = z_soap_codec(assoc->decode, &soap_package,
&hreq->content_buf, &hreq->content_len,
soap_handlers);
#endif
p = z_get_HTTP_Response(o, 200);
hres = p->u.HTTP_Response;
- ret = z_soap_codec(assoc->encode, &soap_package,
- &hres->content_buf, &hres->content_len,
- soap_handlers);
+ ret = z_soap_codec_enc(assoc->encode, &soap_package,
+ &hres->content_buf, &hres->content_len,
+ soap_handlers, charset);
hres->code = http_code;
- z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/xml");
+ if (!charset)
+ z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/xml");
+ else
+ {
+ char ctype[60];
+ strcpy(ctype, "text/xml; charset=");
+ strcat(ctype, charset);
+ z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
+ }
}
if (!p) /* still no response ? */
p = z_get_HTTP_Response(o, 500);
-## $Id: Makefile.am,v 1.10 2003-02-18 10:37:08 adam Exp $
+## $Id: Makefile.am,v 1.11 2003-03-11 11:09:17 adam Exp $
## Copyright (C) 2001, Index Data
AM_CPPFLAGS = -I$(top_srcdir)/include
-noinst_PROGRAMS = zoomtst1 zoomtst2 zoomtst3 zoomtst4 zoomtst5 zoomtst6 zoomtst7 zoomtst8
+EXTRA_PROGRAMS = zoomtst1 zoomtst2 zoomtst3 zoomtst4 zoomtst5 zoomtst6 zoomtst7 zoomtst8
bin_PROGRAMS = zoomsh
LDADD = ../lib/libyazmalloc.la ../lib/libyaz.la $(READLINE_LIBS)
-## $Id: Makefile.am,v 1.18 2003-03-02 15:34:51 adam Exp $
+## $Id: Makefile.am,v 1.19 2003-03-11 11:09:17 adam Exp $
noinst_LTLIBRARIES = libzutil.la
AM_CPPFLAGS=-I$(top_srcdir)/include $(XML2_CFLAGS)
srwtst_LDADD = ../odr/libodr.la libzutil.la ../util/libutil.la
srwtst_SOURCES = srwtst.c
-noinst_PROGRAMS = srwtst
+EXTRA_PROGRAMS = srwtst
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: soap.c,v 1.5 2003-02-18 14:28:53 adam Exp $
+ * $Id: soap.c,v 1.6 2003-03-11 11:09:17 adam Exp $
*/
#include <yaz/soap.h>
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers)
{
+ return z_soap_codec_enc(o, pp, content_buf, content_len, handlers, 0);
+}
+
+int z_soap_codec_enc(ODR o, Z_SOAP **pp,
+ char **content_buf, int *content_len,
+ Z_SOAP_Handler *handlers,
+ const char *encoding)
+{
if (o->direction == ODR_DECODE)
{
Z_SOAP *p;
if (ret)
return ret;
}
- xmlDocDumpMemory(doc, &buf_out, &len_out);
+ if (encoding)
+ xmlDocDumpMemoryEnc(doc, &buf_out, &len_out, encoding);
+ else
+ xmlDocDumpMemory(doc, &buf_out, &len_out);
*content_buf = (char *) odr_malloc(o, len_out);
*content_len = len_out;
memcpy(*content_buf, buf_out, len_out);
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: zgdu.c,v 1.8 2003-02-21 12:08:59 adam Exp $
+ * $Id: zgdu.c,v 1.9 2003-03-11 11:09:17 adam Exp $
*/
#include <yaz/odr.h>
}
else /* ENCODE or PRINT */
{
+ int top0 = o->top;
char sbuf[80];
Z_HTTP_Header *h;
switch((*p)->which)
(*p)->u.HTTP_Response->content_len);
if (o->direction == ODR_PRINT)
{
- fprintf(o->print, "-- HTTP response:\n%.*s\n", o->top, o->buf);
+ fprintf(o->print, "-- HTTP response:\n%.*s\n", o->top - top0,
+ o->buf + top0);
+ fprintf(o->print, "-- \n");
}
break;
case Z_GDU_HTTP_Request:
* Copyright (c) 2000-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.28 2003-02-23 14:26:58 adam Exp $
+ * $Id: zoom-c.c,v 1.29 2003-03-11 11:09:17 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
yaz_log (LOG_DEBUG, "do_connect host=%s", effective_host);
assert (!c->cs);
+ c->cs = cs_create_host (effective_host, 0, &add);
- if (memcmp(c->host_port, "http:", 5) == 0)
+ if (c->cs && c->cs->protocol == PROTO_HTTP)
{
#if HAVE_XML2
- const char *path;
+ const char *path = 0;
+
c->proto = PROTO_HTTP;
- effective_host = c->host_port + 5;
- if (*effective_host == '/')
- effective_host++;
- if (*effective_host == '/')
- effective_host++;
- if (!(path = strchr(effective_host, '/')))
- path = "/";
+ cs_get_host_args(c->host_port, &path);
xfree(c->path);
c->path = xstrdup(path);
#else
- c->state = STATE_IDLE;
set_ZOOM_error(c, ZOOM_ERROR_UNSUPPORTED_PROTOCOL, "SRW");
+ do_close(c);
return zoom_complete;
#endif
}
- c->cs = cs_create_host (effective_host, 0, &add);
-
if (c->cs)
{
int ret = cs_connect (c->cs, add);
#if HAVE_XML2
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_PDU *sr)
{
+ char ctype[50];
Z_SOAP_Handler h[2] = {
{"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec},
{0, 0, 0}
gdu = z_get_HTTP_Request(c->odr_out);
gdu->u.HTTP_Request->path = c->path;
+
+ strcpy(ctype, "text/xml");
+ if (c->charset && strlen(c->charset) < 20)
+ {
+ strcat(ctype, "; charset=");
+ strcat(ctype, c->charset);
+ }
z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
- "Content-Type", "text/xml");
+ "Content-Type", ctype);
z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
"SOAPAction", "\"\"");
p->which = Z_SOAP_generic;
p->u.generic->p = sr;
p->ns = "http://schemas.xmlsoap.org/soap/envelope/";
- ret = z_soap_codec(o, &p,
- &gdu->u.HTTP_Request->content_buf,
- &gdu->u.HTTP_Request->content_len, h);
+ ret = z_soap_codec_enc(o, &p,
+ &gdu->u.HTTP_Request->content_buf,
+ &gdu->u.HTTP_Request->content_len, h,
+ c->charset);
if (!z_GDU(c->odr_out, &gdu, 0, 0))
return zoom_complete;