Beispiel #1
0
CHXString HXCloakedV2TCPSocket::_GetHTTPResourcePath()
{
    //Generate the resource path. Its form depends on if we are going
    //through a proxy or not.   
    if( m_pszProxyName && m_pProxyAddr )
    {
        //We are going through a proxy. We have to add the full server
        //path in there.
        HXURLRep url(HXURLRep::TYPE_NETPATH, "HTTP", _GetHTTPHost(), m_pDestAddr->GetPort(), m_ResourceName);
        HX_ASSERT(url.IsValid());
        return url.String(); 
    }
    
    return CHXString("/") + m_ResourceName;

}
Beispiel #2
0
const CHXString& CHXString::SetFromStr255(const Str255 src)
{
    char temp[256]; /* Flawfinder: ignore */

    if (src==NULL)
    {
        Empty();
    }
    else
    {
        memcpy (temp, &src[1], src[0]); /* Flawfinder: ignore */
        temp[src[0]] = 0;
        *this = CHXString( temp, src[0]);
    }

    return *this;
}
Beispiel #3
0
CHXString HXCloakedV2TCPSocket::_GetProxyAuthString()
{
    IHXBuffer*   pBuffer       = NULL;
    CHXString    retStr        = "";
    CHXString    key           = "proxy-authentication.http:";
    IHXBuffer*   pHeaderBuffer = NULL;
    HX_RESULT    res           = HXR_OK;
    IHXRegistry* pRegistry     = NULL;
    CHXString    recentProxyAuth;
    
    res = m_pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry);
    if( SUCCEEDED(res) )
    {
        res = pRegistry->GetStrByName("proxy-authentication.http.realm.recent", pHeaderBuffer);
        if (SUCCEEDED(res))
        {
            recentProxyAuth = CHXString((const char*)pHeaderBuffer->GetBuffer(),
                                        pHeaderBuffer->GetSize());
        }
        HX_RELEASE(pHeaderBuffer);

        key += m_pszProxyName;
        key += ":";
        key += recentProxyAuth;

        res = pRegistry->GetStrByName((const char*)key, pBuffer);
        if( SUCCEEDED(res) && pBuffer )
        {
            CHXString authString((const char*)pBuffer->GetBuffer(), pBuffer->GetSize());
            retStr = "Proxy-Authorization: ";
            retStr += authString;
        }
        HX_RELEASE(pBuffer);
    }
    HX_RELEASE(pRegistry);

    return retStr;
}
Beispiel #4
0
CHXString ClassOps<CHXString>::Null() const
{
    return CHXString();
}
Beispiel #5
0
STDMETHODIMP HXCloakedV2TCPSocket::ResponseReady( HX_RESULT res, IHXRequest* pRequestResponse)
{
    IHXCommonClassFactory* pCCF       = NULL;
    IHXRegistry*           pRegistry  = NULL;
    IHXValues*             pHeaders   = NULL;
    const char*            pName      = NULL;
    IHXBuffer*             pBuf       = NULL;
    CHXString              key        = "";
    IHXBuffer*             pTmpBuffer = NULL;

    if( SUCCEEDED(res) )
    {
        //Extract the authentication info, again, this is a real waste to just
        //get a username password. See comment in _DoProxyAuthentication.
        res = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);
        if( SUCCEEDED(res) )
        {
            res = m_pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry);
            if( SUCCEEDED(res) )
            {
                res = pRequestResponse->GetRequestHeaders(pHeaders);
                if( SUCCEEDED(res) )
                {
                    res = pHeaders->GetFirstPropertyCString(pName, pBuf);
                    while( SUCCEEDED(res) && pBuf )
                    {
                        if( !strcasecmp(pName, "Proxy-Authorization") )
                        {
                            CHXString  key = "proxy-authentication.http:";
                            key += m_pszProxyName;
                            key += ":";
                            res = pRegistry->GetStrByName( "proxy-authentication.http.realm.recent",
                                                           pTmpBuffer);
                            if( SUCCEEDED(res) )
                            {
                                key += CHXString((const char*)pTmpBuffer->GetBuffer(),
                                                 pTmpBuffer->GetSize());
                            }
                            HX_RELEASE(pTmpBuffer);

                            res = pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pTmpBuffer);
                            if( SUCCEEDED(res) )
                            {
                                pTmpBuffer->Set(pBuf->GetBuffer(), pBuf->GetSize());
                                
                                UINT32 regid = pRegistry->GetId((const char*)key);
                                if (!regid)
                                {
                                    pRegistry->AddStr((const char*)key, pTmpBuffer);
                                }
                                else
                                {
                                    pRegistry->SetStrByName((const char*)key, pTmpBuffer);
                                }
                            }
                            HX_RELEASE(pTmpBuffer);
                            break;
                        }

                        // get next header name value line
                        HX_RELEASE(pBuf);
                        res = pHeaders->GetNextPropertyCString(pName, pBuf);
                    }
                    HX_RELEASE(pBuf);
                    HX_RELEASE(pHeaders);
                }
            }
            HX_RELEASE(pRegistry);
        }
        HX_RELEASE(pCCF);
    }
    
    HX_RELEASE(pRequestResponse);

    //We need to start over connting again....
    m_CloakingState = csDisconnected;
    if( m_pTCPSocket)
    {
        m_pTCPSocket->Close();
        HX_RELEASE(m_pTCPSocket);
    }
    
    res = m_pNetworkServices->CreateSocket(&m_pTCPSocket);
    if(m_pTCPSocket && SUCCEEDED(res) )
    {
        res = m_pTCPSocket->SetResponse(this);
        if( SUCCEEDED(res) )
        {
            res = m_pTCPSocket->Init(m_family, m_type, m_protocol);
            m_pTCPSocket->SetOption( HX_SOCKOPT_APP_BUFFER_TYPE,
                                     HX_SOCKBUF_DEFAULT);
            m_pTCPSocket->SelectEvents(HX_SOCK_EVENT_READ|
                                       HX_SOCK_EVENT_CONNECT|
                                       HX_SOCK_EVENT_CLOSE);
        
            res = m_pTCPSocket->ConnectToOne(m_pDestAddr);
        }
    }

    return res;
}