X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=86da0d825b8f7d153879a59d7283037e3fce9f64;hb=38a84b0abd51728d3fc7c3451f764d2cb81994dc;hp=0e423d94a1f78c5464dd03b1584600131a434aeb;hpb=ab79448b67b5b423fe2d5c68124e94ad27fc8ecd;p=yazpp-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 0e423d9..86da0d8 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.97 2004-02-02 15:11:41 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.102 2004-02-16 10:47:37 adam Exp $ */ #include @@ -101,6 +101,7 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable, m_request_no = 0; m_invalid_session = 0; m_referenceId = 0; + m_referenceId_mem = nmem_create(); m_config = 0; m_marcxml_flag = 0; m_stylesheet_xsp = 0; @@ -133,6 +134,8 @@ Yaz_Proxy::~Yaz_Proxy() m_bytes_sent, m_bytes_recv); nmem_destroy(m_initRequest_mem); nmem_destroy(m_mem_invalid_session); + nmem_destroy(m_referenceId_mem); + xfree (m_proxyTarget); xfree (m_default_target); xfree (m_proxy_authentication); @@ -635,7 +638,7 @@ void Yaz_Proxy::convert_xsl_delay() xsltFreeStylesheet(m_stylesheet_xsp); m_stylesheet_xsp = 0; timeout(m_client_idletime); - int r = send_PDU_convert(m_stylesheet_apdu); + send_PDU_convert(m_stylesheet_apdu); } else timeout(0); @@ -893,6 +896,7 @@ int Yaz_Proxy::send_srw_explain_response(Z_SRW_diagnostic *diagnostics, er->record.recordData_buf = b; er->record.recordData_len = len; er->record.recordPacking = m_s2z_packing; + er->record.recordSchema = "http://explain.z3950.org/dtd/2.0/"; er->diagnostics = diagnostics; er->num_diagnostics = num_diagnostics; @@ -982,7 +986,7 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu) Z_ReferenceId **new_id = get_referenceIdP(apdu); if (new_id && m_referenceId) - *new_id = *m_referenceId; + *new_id = m_referenceId; if (apdu->which == Z_APDU_searchResponse) { @@ -1917,6 +1921,20 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq) void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) { + Z_ReferenceId **refid = get_referenceIdP(apdu); + nmem_reset(m_referenceId_mem); + if (refid && *refid) + { + m_referenceId = (Z_ReferenceId *) + nmem_malloc(m_referenceId_mem, sizeof(*m_referenceId)); + m_referenceId->len = m_referenceId->size = (*refid)->len; + m_referenceId->buf = (unsigned char *) + nmem_malloc(m_referenceId_mem, (*refid)->len); + memcpy(m_referenceId->buf, (*refid)->buf, (*refid)->len); + } + else + m_referenceId = 0; + if (!m_client && m_invalid_session) { m_apdu_invalid_session = apdu; @@ -1924,8 +1942,6 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) apdu = m_initRequest_apdu; } - m_referenceId = get_referenceIdP(apdu); - // Determine our client. Z_OtherInformation **oi; get_otherInfoAPDU(apdu, &oi); @@ -1967,6 +1983,8 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) ODR_MASK_SET(apdu->u.initRequest->options, i); ODR_MASK_CLEAR(apdu->u.initRequest->options, Z_Options_negotiationModel); + ODR_MASK_CLEAR(apdu->u.initRequest->options, + Z_Options_concurrentOperations); // make new version m_initRequest_version = apdu->u.initRequest->protocolVersion; @@ -1982,19 +2000,22 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) { if (handle_init_response_for_invalid_session(apdu)) return; - Z_APDU *apdu2 = m_client->m_initResponse; - apdu2->u.initResponse->otherInfo = 0; - if (m_client->m_cookie && *m_client->m_cookie) - set_otherInformationString(apdu2, VAL_COOKIE, 1, - m_client->m_cookie); - apdu2->u.initResponse->referenceId = - apdu->u.initRequest->referenceId; - apdu2->u.initResponse->options = m_client->m_initResponse_options; - apdu2->u.initResponse->protocolVersion = - m_client->m_initResponse_version; - - send_to_client(apdu2); - return; + if (m_client->m_initResponse) + { + Z_APDU *apdu2 = m_client->m_initResponse; + apdu2->u.initResponse->otherInfo = 0; + if (m_client->m_cookie && *m_client->m_cookie) + set_otherInformationString(apdu2, VAL_COOKIE, 1, + m_client->m_cookie); + apdu2->u.initResponse->referenceId = + apdu->u.initRequest->referenceId; + apdu2->u.initResponse->options = m_client->m_initResponse_options; + apdu2->u.initResponse->protocolVersion = + m_client->m_initResponse_version; + + send_to_client(apdu2); + return; + } } m_client->m_init_flag = 1; } @@ -2163,6 +2184,8 @@ void Yaz_ProxyClient::pre_init_client() ODR_MASK_SET(req->options, i); ODR_MASK_CLEAR(apdu->u.initRequest->options, Z_Options_negotiationModel); + ODR_MASK_CLEAR(apdu->u.initRequest->options, + Z_Options_concurrentOperations); for (i = 0; i<= 10; i++) ODR_MASK_SET(req->protocolVersion, i);