String makeHeadersString() { String strRes = ""; foreach (KeyValuePair <String, String> kvp in m_mapHeaders) { if (strRes.length() > 0) { strRes += "&"; } strRes += "headers["; strRes += URI.urlEncode(kvp.Key.ToString()); strRes += "]="; strRes += URI.urlEncode(kvp.Value.ToString()); } return(strRes); }
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); } } }