bool CNcbiCommand::IsRequested( const CCgiContext& ctx ) const { const string value = GetName(); TCgiEntries& entries = const_cast<TCgiEntries&>(ctx.GetRequest().GetEntries()); pair<TCgiEntriesI,TCgiEntriesI> p = entries.equal_range( GetEntry() ); for ( TCgiEntriesI itEntr = p.first; itEntr != p.second; ++itEntr ) { if( AStrEquiv( value, itEntr->second, PNocase() ) ) { return true; } // if } // for // if there is no 'cmd' entry // check the same for IMAGE value p = entries.equal_range( NcbiEmptyString ); for ( TCgiEntriesI iti = p.first; iti != p.second; ++iti ) { if( AStrEquiv( value, iti->second, PNocase() ) ) { return true; } // if } return false; }
bool CId_pat::Id_Match(const C_Id& id1, const C_Id& id2) { C_Id::E_Choice type1 = id1.Which(); C_Id::E_Choice type2 = id2.Which(); if (type1 != type2) return false; switch ( type1 ) { case C_Id::e_Number: return AStrEquiv(id1.GetNumber(), id2.GetNumber(), PNocase()); case C_Id::e_App_number: return AStrEquiv(id1.GetApp_number(), id2.GetApp_number(), PNocase()); default: return false; } }
const string& CCgiContext::GetSelfURL(void) const { if ( !m_SelfURL.empty() ) return m_SelfURL; // First check forwarded URLs string caf_url = GetRequest().GetRandomProperty("CAF_URL"); if ( !caf_url.empty() ) { m_SelfURL = caf_url; return m_SelfURL; } // Compose self URL string server(GetRequest().GetProperty(eCgi_ServerName)); if ( server.empty() ) { return kEmptyStr; } bool secure = AStrEquiv(GetRequest().GetRandomProperty("HTTPS", false), "on", PNocase()); m_SelfURL = secure ? "https://" : "http://"; m_SelfURL += server; string port = GetRequest().GetProperty(eCgi_ServerPort); // Skip port if it's default for the selected scheme if ((secure && port == "443") || (!secure && port == "80") || (server.size() >= port.size() + 2 && NStr::EndsWith(server, port) && server[server.size() - port.size() - 1] == ':')) { port = kEmptyStr; } if ( !port.empty() ) { m_SelfURL += ':'; m_SelfURL += port; } // (replace adjacent '//' to work around a bug in the "www.ncbi" proxy; // it should not hurt, and may help with similar proxies outside NCBI) string script_uri; script_uri = GetRequest().GetRandomProperty("SCRIPT_URL", false); if ( script_uri.empty() ) { script_uri = GetRequest().GetProperty(eCgi_ScriptName); } // Remove args if any size_t arg_pos = script_uri.find('?'); if (arg_pos != NPOS) { script_uri = script_uri.substr(0, arg_pos); } m_SelfURL += NStr::Replace(script_uri, "//", "/"); return m_SelfURL; }
// comparison function bool CId_pat::Match(const CId_pat& idp2) const { return AStrEquiv(GetCountry(), idp2.GetCountry(), PNocase()) && Id_Match(GetId(), idp2.GetId()); }