+void Yaz_Proxy::handle_charset_lang_negotiation(Z_APDU *apdu)
+{
+ if (apdu->which == Z_APDU_initRequest)
+ {
+ if (m_initRequest_options &&
+ !ODR_MASK_GET(m_initRequest_options, Z_Options_negotiationModel) &&
+ (m_proxy_negotiation_charset || m_proxy_negotiation_lang))
+ {
+ // There is not negotiation proposal from
+ // client's side. OK. The proxy negotiation
+ // in use, only.
+ Z_InitRequest *initRequest = apdu->u.initRequest;
+ Z_OtherInformation **otherInfo;
+ Z_OtherInformationUnit *oi;
+ get_otherInfoAPDU(apdu, &otherInfo);
+ oi = update_otherInformation(otherInfo, 1, NULL, 0, 0);
+ if (oi)
+ {
+ ODR_MASK_SET(initRequest->options,
+ Z_Options_negotiationModel);
+ oi->which = Z_OtherInfo_externallyDefinedInfo;
+ oi->information.externallyDefinedInfo =
+ yaz_set_proposal_charneg(odr_encode(),
+ (const char**)&m_proxy_negotiation_charset,
+ m_proxy_negotiation_charset ? 1:0,
+ (const char**)&m_proxy_negotiation_lang,
+ m_proxy_negotiation_lang ? 1:0,
+ 1);
+ }
+ }
+ }
+ else if (apdu->which == Z_APDU_initResponse)
+ {
+ Z_InitResponse *initResponse = apdu->u.initResponse;
+ Z_OtherInformation **otherInfo;
+ Z_OtherInformationUnit *oi;
+
+ if (ODR_MASK_GET(initResponse->options, Z_Options_negotiationModel))
+ {
+ char *charset = 0;
+ char *lang = 0;
+ int selected = 0;
+
+ get_otherInfoAPDU(apdu, &otherInfo);
+
+ if (!otherInfo && !(*otherInfo))
+ return;
+
+ Z_CharSetandLanguageNegotiation *charneg =
+ yaz_get_charneg_record(*otherInfo);
+
+ if (!charneg)
+ return;
+
+ yaz_get_response_charneg(m_referenceId_mem, charneg,
+ &charset, &lang, &selected);
+
+ yaz_log(YLOG_LOG, "%sAccepted charset - '%s' and lang - '%s'",
+ m_session_str, (charset)?charset:"none", (lang)?lang:"none");
+
+ if (m_initRequest_options &&
+ ODR_MASK_GET(m_initRequest_options, Z_Options_negotiationModel))
+ {
+ yaz_log(YLOG_LOG, "%sClient's negotiation record in use",
+ m_session_str);
+ }
+ else if (m_proxy_negotiation_charset || m_proxy_negotiation_lang)
+ {
+ // negotiation-charset, negotiation-lang
+ // elements of config file in use.
+
+ yaz_log(YLOG_LOG, "%sProxy's negotiation record in use",
+ m_session_str);