+ package.session().close();
+ return false;
+}
+
+
+bool yf::SRUtoZ3950::Rep::build_sru_response(mp::Package &package,
+ mp::odr &odr_en,
+ Z_SOAP *soap,
+ const Z_SRW_PDU *sru_pdu_res,
+ char *charset,
+ const char *stylesheet)
+ const
+{
+
+ // SRU request package translation to Z3950 package
+ if (sru_pdu_res)
+ std::cout << *(const_cast<Z_SRW_PDU *>(sru_pdu_res)) << "\n";
+ else
+ std::cout << "SRU empty\n";
+
+
+ Z_GDU *zgdu_req = package.request().get();
+ if (zgdu_req && zgdu_req->which == Z_GDU_HTTP_Request)
+ {
+ Z_GDU *zgdu_res //= z_get_HTTP_Response(odr_en, 200);
+ = odr_en.create_HTTP_Response(package.session(),
+ zgdu_req->u.HTTP_Request,
+ 200);
+
+ // adding HTTP response code and headers
+ Z_HTTP_Response * http_res = zgdu_res->u.HTTP_Response;
+ //http_res->code = http_code;
+
+ std::string ctype("text/xml");
+ if (charset){
+ ctype += "; charset=";
+ ctype += charset;
+ }
+
+ z_HTTP_header_add(odr_en,
+ &http_res->headers, "Content-Type", ctype.c_str());
+
+ // packaging Z_SOAP into HTML response
+ static Z_SOAP_Handler soap_handlers[4] = {
+ {"http://www.loc.gov/zing/srw/", 0,
+ (Z_SOAP_fun) yaz_srw_codec},
+ {"http://www.loc.gov/zing/srw/v1.0/", 0,
+ (Z_SOAP_fun) yaz_srw_codec},
+ {"http://www.loc.gov/zing/srw/update/", 0,
+ (Z_SOAP_fun) yaz_ucp_codec},
+ {0, 0, 0}
+ };
+
+
+ // empty stylesheet means NO stylesheet
+ if (stylesheet && *stylesheet == '\0')
+ stylesheet = 0;
+
+ // encoding SRU package
+
+ soap->u.generic->p = (void*) sru_pdu_res;
+ //int ret =
+ z_soap_codec_enc_xsl(odr_en, &soap,
+ &http_res->content_buf, &http_res->content_len,
+ soap_handlers, charset, stylesheet);
+
+
+ package.response() = zgdu_res;
+ return true;
+ }
+ package.session().close();