diff --git a/cli/restclient.c b/cli/restclient.c index b76e61b..142d229 100644 --- a/cli/restclient.c +++ b/cli/restclient.c @@ -18,17 +18,6 @@ int trace_fn(CURL *handle, curl_infotype type, char *data, size_t size, void *userp); -static size_t -write_mem_cb( - void *contents, - size_t size, - size_t nmemb, - void *userp) -{ - printf("%s\n", (char *)contents); - return size * nmemb; -} - uint32_t call_rest_method( const char *pszUrl, @@ -39,7 +28,7 @@ call_rest_method( uint32_t dwError = 0; CURL *pCurl = NULL; CURLcode res = CURLE_OK; - int nStatus = 0; + long nStatus = 0; if(IsNullOrEmptyString(pszUrl) || !pMethod || !pArgs) { @@ -104,12 +93,11 @@ call_rest_method( BAIL_ON_CURL_ERROR(dwError); } - dwError = curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_mem_cb); - BAIL_ON_CURL_ERROR(dwError); - dwError = curl_easy_perform(pCurl); BAIL_ON_CURL_ERROR(dwError); + fprintf(stdout, "\n"); + dwError = curl_easy_getinfo(pCurl, CURLINFO_RESPONSE_CODE, &nStatus); BAIL_ON_CURL_ERROR(dwError); @@ -122,7 +110,7 @@ call_rest_method( } else { - fprintf(stderr, "Error: server returned %d\n", nStatus); + fprintf(stderr, "Error: server returned %ld\n", nStatus); } dwError = 1; BAIL_ON_ERROR(dwError);