}
else
{
- ret = ZOOM_handle_sru(c, hres, &cret);
+ ret = ZOOM_handle_sru(c, hres, &cret, &addinfo);
if (ret == 0)
{
if (c->no_redirects) /* end of redirect. change hosts again */
if (hres->code != 200)
ZOOM_set_HTTP_error(c, hres->code, 0, 0);
else
+ {
+ yaz_log(YLOG_LOG, "set error... addinfo=%s", addinfo ?
+ addinfo : "NULL");
ZOOM_set_error(c, ZOOM_ERROR_DECODE, addinfo);
+ }
ZOOM_connection_close(c);
}
if (cret == zoom_complete)
zoom_ret ZOOM_connection_srw_send_scan(ZOOM_connection c);
int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres,
- zoom_ret *cret);
+ zoom_ret *cret, char **addinfo);
void ZOOM_set_HTTP_error(ZOOM_connection c, int error,
const char *addinfo, const char *addinfo2);
#endif
int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres,
- zoom_ret *cret)
+ zoom_ret *cret, char **addinfo)
{
#if YAZ_HAVE_XML2
int ret = 0;
- const char *addinfo = 0;
/* not redirect (normal response) */
if (!yaz_srw_check_content_type(hres))
{
- addinfo = "content-type";
+ *addinfo = "content-type";
ret = -1;
}
else if (c->sru_mode == zoom_sru_solr)
soap_package->u.fault->fault_string);
}
else
+ {
+ size_t max_chars = 1000;
+ size_t sz = hres->content_len;
+ if (sz > max_chars - 1)
+ sz = max_chars;
+ *addinfo = odr_malloc(c->odr_in, sz + 4);
+ memcpy(*addinfo, hres->content_buf, sz);
+ if (sz == max_chars)
+ strcpy(*addinfo + sz, "...");
+ else
+ strcpy(*addinfo + sz, "");
ret = -1;
+ }
}
return ret;
#else