Пример #1
0
wxString wxURI::GetPassword() const
{
      size_t posColon = m_userinfo.find(':');

      if ( posColon == wxString::npos )
          return "";

      return m_userinfo(posColon + 1, wxString::npos);
}
Пример #2
0
// ---------------------------------------------------------------------------
// GetUser
// GetPassword
//
// Gets the username and password via the old URL method.
// ---------------------------------------------------------------------------
wxString wxURI::GetUser() const
{
    // if there is no colon at all, find() returns npos and this method returns
    // the entire string which is correct as it means that password was omitted
    return m_userinfo(0, m_userinfo.find(':'));
}
Пример #3
0
wxInputStream *wxURL::GetInputStream()
{
    if (!m_protocol)
    {
        m_error = wxURL_NOPROTO;
        return NULL;
    }

    m_error = wxURL_NOERR;
    if (HasUserInfo())
    {
        size_t dwPasswordPos = m_userinfo.find(':');

        if (dwPasswordPos == wxString::npos)
            m_protocol->SetUser(m_userinfo);
        else
        {
            m_protocol->SetUser(m_userinfo(0, dwPasswordPos));
            m_protocol->SetPassword(m_userinfo(dwPasswordPos+1, m_userinfo.length() + 1));
        }
    }

#if wxUSE_URL_NATIVE
    // give the native implementation to return a better stream
    // such as the native WinINet functionality under MS-Windows
    if (m_nativeImp)
    {
        wxInputStream *rc;
        rc = m_nativeImp->GetInputStream(this);
        if (rc != 0)
            return rc;
    }
    // else use the standard behaviour
#endif // wxUSE_URL_NATIVE

#if wxUSE_SOCKETS
    wxIPV4address addr;

    // m_protoinfo is NULL when we use a proxy
    if (!m_useProxy && m_protoinfo->m_needhost)
    {
        if (!addr.Hostname(m_server))
        {
            m_error = wxURL_NOHOST;
            return NULL;
        }

        addr.Service(m_port);

        if (!m_protocol->Connect(addr, true)) // Watcom needs the 2nd arg for some reason
        {
            m_error = wxURL_CONNERR;
            return NULL;
        }
    }
#endif

    // When we use a proxy, we have to pass the whole URL to it.
    wxInputStream *the_i_stream;

    if (!m_useProxy)
    {
        the_i_stream = m_protocol->GetInputStream(m_url);
    }
    else
    {
        wxString fullPath = m_path;

        if (HasQuery())
            fullPath += wxT("?") + m_query;

        if (HasFragment())
            fullPath += wxT("#") + m_fragment;

        the_i_stream = m_protocol->GetInputStream(fullPath);
    }

    if (!the_i_stream)
    {
        m_error = wxURL_PROTOERR;
        return NULL;
    }

    return the_i_stream;
}