|
|
@ -21,7 +21,6 @@ static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid)
|
|
|
|
|
|
|
|
|
|
|
|
static int SockOptCallback(void *clientp, curl_socket_t curlfd, curlsocktype purpose)
|
|
|
|
static int SockOptCallback(void *clientp, curl_socket_t curlfd, curlsocktype purpose)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
net_handle_t netHandle = *((net_handle_t *)clientp);
|
|
|
|
net_handle_t netHandle = *((net_handle_t *)clientp);
|
|
|
|
|
|
|
|
|
|
|
|
int res = android_setsocknetwork(netHandle, curlfd);
|
|
|
|
int res = android_setsocknetwork(netHandle, curlfd);
|
|
|
@ -34,7 +33,7 @@ static int SockOptCallback(void *clientp, curl_socket_t curlfd, curlsocktype pur
|
|
|
|
return res == 0 ? CURL_SOCKOPT_OK : CURL_SOCKOPT_ERROR;
|
|
|
|
return res == 0 ? CURL_SOCKOPT_OK : CURL_SOCKOPT_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DoGetRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, std::vector<uint8_t>& data)
|
|
|
|
int DoGetRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, std::vector<uint8_t>& data, int* curlResVal/* = NULL*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CURLcode nRet;
|
|
|
|
CURLcode nRet;
|
|
|
|
std::string auth;
|
|
|
|
std::string auth;
|
|
|
@ -88,6 +87,10 @@ int DoGetRequest(const char* url, int authType, const char* userName, const char
|
|
|
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
|
|
|
|
|
|
|
|
nRet = curl_easy_perform(curl);
|
|
|
|
nRet = curl_easy_perform(curl);
|
|
|
|
|
|
|
|
if (curlResVal != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*curlResVal = nRet;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long responseCode = 0;
|
|
|
|
long responseCode = 0;
|
|
|
|
if (CURLE_OK == nRet)
|
|
|
|
if (CURLE_OK == nRet)
|
|
|
@ -122,7 +125,7 @@ int DoGetRequest(const char* url, int authType, const char* userName, const char
|
|
|
|
return ((0 == nRet) && (responseCode == 200)) ? 0 : 1;
|
|
|
|
return ((0 == nRet) && (responseCode == 200)) ? 0 : 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector<uint8_t>& data)
|
|
|
|
int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector<uint8_t>& data, int* curlResVal/* = NULL*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string auth;
|
|
|
|
std::string auth;
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +174,10 @@ int DoPutRequest(const char* url, int authType, const char* userName, const char
|
|
|
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
|
|
|
|
|
|
|
|
CURLcode nRet = curl_easy_perform(curl);
|
|
|
|
CURLcode nRet = curl_easy_perform(curl);
|
|
|
|
|
|
|
|
if (curlResVal != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*curlResVal = nRet;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (CURLE_OK != nRet)
|
|
|
|
if (CURLE_OK != nRet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("GET err=%d", nRet);
|
|
|
|
printf("GET err=%d", nRet);
|
|
|
|