示例#1
0
            void processResponse(NetResponse resp)
            {
                if (resp.isOK() && m_mapHeaders != null)
                {
                    String strContType = null;
                    m_mapHeaders.TryGetValue("content-type", out strContType);
                    if (strContType != null && strContType.indexOf("application/json") >= 0)
                    {
                        try{
                            m_valBody = fastJSON.RJSONTokener.JsonDecode(resp.getCharData());
                            return;
                        }catch (Exception exc)
                        {
                            LOG.ERROR("Incorrect json body.", exc);
                        }
                    }
                }

                m_valBody = CRhoRuby.create_string(resp.getCharData());
            }
示例#2
0
        public NetResponse pullCookies(String strUrl, String strBody, IRhoSession oSession)
        {
            Hashtable <String, String> headers = new Hashtable <String, String>();

            m_bCancel = false;

            NetResponse resp = doRequest/*Try*/ ("POST", strUrl, strBody, oSession, headers);

            if (resp.isOK())
            {
                String strCookie = resp.getCookies();
                if (strCookie == null || strCookie.length() == 0)
                {
                    strCookie = "rho_empty";
                }

                resp.setCharData(strCookie);
                LOG.INFO("pullCookies: " + resp.getCharData());
            }

            return(resp);
        }
示例#3
0
    	    void processResponse(NetResponse resp )
    	    {
    	        if (resp.isOK() && m_mapHeaders != null)
    	        {
    	    	    String strContType = null;
                    m_mapHeaders.TryGetValue("content-type", out strContType);
    	    	    if ( strContType != null && strContType.indexOf("application/json") >=0 )
    	    	    {   
    	    		    try{
                            m_valBody = fastJSON.RJSONTokener.JsonDecode(resp.getCharData());
    	    			    return;
    	    		    }catch(Exception exc)
    	    		    {
    	    			    LOG.ERROR("Incorrect json body.", exc);
    	    		    }
    	    	    }
    	        }

    	        m_valBody = CRhoRuby.create_string(resp.getCharData());
    	    }
示例#4
0
            void callNotify(NetResponse resp, int nError)
            {
                if (m_bInternal)
                {
                    return;
                }

                m_strResBody  = "rho_callback=1";
                m_strResBody += "&status=";
                if (nError > 0)
                {
                    m_strResBody += "error&error_code=" + nError;
                }
                else
                {
                    if (resp.isOK())
                    {
                        m_strResBody += "ok";
                    }
                    else
                    {
                        m_strResBody += "error&error_code=";
                        m_strResBody += RhoAppAdapter.getErrorFromResponse(resp);
                        //if ( resp.isResponseRecieved())
                        m_strResBody += "&http_error=" + 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(m_valBody, "body");
                }

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

                if (m_strCallback.length() > 0)
                {
                    try{
                        String      strFullUrl = m_pNetRequest.resolveUrl(m_strCallback);
                        NetResponse resp1      = m_pNetRequest.pushData(strFullUrl, m_strResBody, null);
                        if (!resp1.isOK())
                        {
                            LOG.ERROR("AsyncHttp notification failed. Code: " + resp1.getRespCode() + "; Error body: " + resp1.getCharData());
                        }
                    }catch (Exception exc)
                    {
                        LOG.ERROR("Async http callback failed.", exc);
                    }
                }
            }