예제 #1
0
void CAsyncHttp::CHttpCommand::callNotify(NetResponse& resp, int nError )
{
    m_strResBody = "rho_callback=1";
    m_strResBody += "&status=";
    if ( nError > 0 )
    {
    	m_strResBody += "error&error_code=" + nError;
    }else
    {
        if ( resp.isSuccess() )
        {
    	    m_strResBody += "ok";
            if ( resp.isResponseRecieved())
	            m_strResBody += "&http_error=" + convertToStringA(resp.getRespCode());
        }
        else
        {
    	    m_strResBody += "error&error_code=";
            m_strResBody += convertToStringA(RhoAppAdapter.getErrorFromResponse(resp));
            if ( resp.isResponseRecieved())
	            m_strResBody += "&http_error=" + convertToStringA(resp.getRespCode());
        }

        String cookies = resp.getCookies();
        if (cookies.length()>0)
            m_strResBody += "&cookies=" + URI::urlEncode(cookies);

        String strHeaders = makeHeadersString();
        if (strHeaders.length() > 0 )
            m_strResBody += "&" + strHeaders;

        m_strResBody += "&" + RHODESAPP().addCallbackObject(
            new CAsyncHttpResponse(resp, m_mapHeaders.get("content-type")), "body");
    }

    if ( m_strCallbackParams.length() > 0 )
        m_strResBody += "&" + m_strCallbackParams;

    if ( m_strCallback.length() > 0 )
    {
        String strFullUrl = m_NetRequest.resolveUrl(m_strCallback);
        getNet().pushData( strFullUrl, m_strResBody, null );
    }
}
예제 #2
0
	/*static*/ int  _CRhoAppAdapter::getErrorFromResponse(NetResponse& resp)
	{
		if ( !resp.isResponseRecieved())
			return ERR_NETWORK;
		
		if ( resp.isUnathorized() )
			return ERR_UNATHORIZED;
		
		if ( !resp.isOK() )
			return ERR_REMOTESERVER;
		
		return ERR_NONE;
	}