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); }
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); } } }
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); } } }