X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=8a5a27e70781798a6f2904655654878d62007fdc;hb=113c16a5254c24ec5dfc1b72a2b124f0bd356501;hp=7da3e15a6f4442d3dfbf3fd60e2534c48d90a3ca;hpb=277e55dae549f6fa6b9ad22d8ebd89af53bcd71b;p=yazpp-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 7da3e15..8a5a27e 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.76 2004-01-05 11:31:04 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.79 2004-01-07 11:37:45 adam Exp $ */ #include @@ -107,6 +107,7 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable, m_config = 0; m_marcxml_flag = 0; m_stylesheet = 0; + m_schema = 0; m_initRequest_apdu = 0; m_initRequest_mem = 0; m_apdu_invalid_session = 0; @@ -135,6 +136,7 @@ Yaz_Proxy::~Yaz_Proxy() xfree (m_proxy_authentication); xfree (m_optimize); xfree (m_stylesheet); + xfree (m_schema); if (m_s2z_odr_init) odr_destroy(m_s2z_odr_init); if (m_s2z_odr_search) @@ -815,7 +817,7 @@ int Yaz_Proxy::send_to_srw_client_ok(int hits, Z_Records *records, int start) oident *ent = oid_getentbyoid(r->direct_reference); if (r->which == Z_External_octet && ent->value == VAL_TEXT_XML) { - srw_res->records[i].recordSchema = "http://www.loc.gov/marcxml/"; + srw_res->records[i].recordSchema = m_schema; srw_res->records[i].recordPacking = m_s2z_packing; srw_res->records[i].recordData_buf = (char*) r->u.octet_aligned->buf; @@ -1017,11 +1019,12 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu) int Yaz_ProxyClient::send_to_target(Z_APDU *apdu) { int len = 0; + const char *apdu_name_tmp = apdu_name(apdu); int r = send_Z_PDU(apdu, &len); if (m_root->get_log_mask() & PROXY_LOG_REQ_SERVER) yaz_log (LOG_LOG, "%sSending %s to %s %d bytes", get_session_str(), - apdu_name(apdu), get_hostname(), len); + apdu_name_tmp, get_hostname(), len); m_bytes_sent += len; return r; } @@ -1360,16 +1363,32 @@ Z_APDU *Yaz_Proxy::handle_query_transformation(Z_APDU *apdu) { Z_RPNQuery *rpnquery = 0; Z_SearchRequest *sr = apdu->u.searchRequest; + char *addinfo = 0; yaz_log(LOG_LOG, "%sCQL: %s", m_session_str, sr->query->u.type_104->u.cql); int r = m_cql2rpn.query_transform(sr->query->u.type_104->u.cql, - &rpnquery, odr_encode()); + &rpnquery, odr_encode(), + &addinfo); if (r == -3) yaz_log(LOG_LOG, "%sNo CQL to RPN table", m_session_str); else if (r) + { yaz_log(LOG_LOG, "%sCQL Conversion error %d", m_session_str, r); + Z_APDU *new_apdu = create_Z_PDU(Z_APDU_searchResponse); + + new_apdu->u.searchResponse->referenceId = sr->referenceId; + new_apdu->u.searchResponse->records = + create_nonSurrogateDiagnostics(odr_encode(), + yaz_diag_srw_to_bib1(r), + addinfo); + *new_apdu->u.searchResponse->searchStatus = 0; + + send_to_client(new_apdu); + + return 0; + } else { sr->query->which = Z_Query_type_1; @@ -1431,7 +1450,7 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu) err = cfg->check_syntax(odr_encode(), m_default_target, sr->preferredRecordSyntax, rc, - &addinfo, &m_stylesheet); + &addinfo, &m_stylesheet, &m_schema); if (err == -1) { sr->preferredRecordSyntax = @@ -1463,7 +1482,7 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu) err = cfg->check_syntax(odr_encode(), m_default_target, pr->preferredRecordSyntax, pr->recordComposition, - &addinfo, &m_stylesheet); + &addinfo, &m_stylesheet, &m_schema); if (err == -1) { pr->preferredRecordSyntax = @@ -1631,7 +1650,9 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq) start = *srw_req->startRecord; if (max > 0) { - if (start <= 1) // Z39.50 piggyback + // Some backend, such as Voyager doesn't honor piggyback + // So we use present always (0 &&). + if (0 && start <= 1) // Z39.50 piggyback { *z_searchRequest->smallSetUpperBound = max; *z_searchRequest->mediumSetPresentNumber = max; @@ -2248,7 +2269,7 @@ int Yaz_Proxy::server(const char *addr) int r = Yaz_Z_Assoc::server(addr); if (!r) { - yaz_log(LOG_LOG, "%sStarted listener on %s", m_session_str, addr); + yaz_log(LOG_LOG, "%sStarted proxy " VERSION " on %s", m_session_str, addr); timeout(1); } return r;