- mp::odr odr;
- package.response() = odr.create_initResponse(
- apdu,
- YAZ_BIB1_INIT_NEGOTIATION_OPTION_REQUIRED,
- "z3950_client: No virtal host given");
-
- package.session().close();
- return 0;
- }
- if (no_vhosts > 1)
- {
- mp::odr odr;
- package.response() = odr.create_initResponse(
- apdu,
- YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP,
- "z3950_client: Can not cope with multiple vhosts");
- package.session().close();
- return 0;
+ target = m_default_target;
+ std::list<std::string> vhosts;
+ mp::util::remove_vhost_otherinfo(&apdu->u.initRequest->otherInfo,
+ vhosts);
+ size_t no_vhosts = vhosts.size();
+ if (no_vhosts == 1)
+ {
+ std::list<std::string>::const_iterator v_it = vhosts.begin();
+ target = *v_it;
+ }
+ else if (no_vhosts == 0)
+ {
+ if (!target.length())
+ {
+ // no default target. So we don't know where to connect
+ mp::odr odr;
+ package.response() = odr.create_initResponse(
+ apdu,
+ YAZ_BIB1_INIT_NEGOTIATION_OPTION_REQUIRED,
+ "z3950_client: No virtal host given");
+
+ package.session().close();
+ return 0;
+ }
+ }
+ else if (no_vhosts > 1)
+ {
+ mp::odr odr;
+ package.response() = odr.create_initResponse(
+ apdu,
+ YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP,
+ "z3950_client: Can not cope with multiple vhosts");
+ package.session().close();
+ return 0;
+ }