bool CHttpClient::HttpPost(const char *url, const void * postData, int nPostDataSize, CHttpClientResponse &resp, bool formflag) { bool retVal = 1; for(int i = 0; i < HTTP_MAX_RETRIES; i++) { if( (retVal = DoPostInternal(url, postData, nPostDataSize, resp, formflag)) == 0) { if (resp.GetBodyLength() == 0) { //logFile.Write(LOG_BASIC, "HTTP POST returned no data - trying again..."); } else if (i > 0) { //logFile.Write(LOG_BASIC, "HTTP POST finally succeeded"); } break; } #ifdef SCUT_WIN32 Sleep(1000); #elif SCUT_ANDROID usleep(1000); #else usleep(1000); #endif } if (resp.GetBodyLength() == 0) { //logFile.Write(LOG_BASIC, "HTTP POST returned no data - returning failure..."); //retVal = 1; } return retVal; }
/******************************************************************* * Function : DoGet() * Parameters: url - The URL to which an HTTP GET is to be done * resp - The response object which will store the HTTP * response received from the website * Returns : 0 - GET succeeded (could have any HTTP errors, * including 404 errors) * 1 - The GET failed most likely because a * connection coul not be established * Purpose : To do an HTTP GET with a max of HTTP_MAX_RETRIES retries *******************************************************************/ int CHttpClient::HttpGet(const char *url, CHttpClientResponse &resp) { int nRet = 1; for(int i = 0; i < HTTP_MAX_RETRIES; i++) { if ((nRet = DoGetInternal(url, resp)) == 0) { if (resp.GetBodyLength() == 0) { //logFile.Write(LOG_BASIC, "HTTP GET returned no data - trying again..."); } else if (i > 0) { //logFile.Write(LOG_BASIC, "HTTP GET finally succeeded"); } break; } FullReset(); #ifdef SCUT_WIN32 Sleep(1000); #elif SCUT_ANDROID usleep(1000); #else usleep(1000); #endif } return nRet; }