Skip to content

Commit

Permalink
Make sure it httpDelete returns what it's supposed to return
Browse files Browse the repository at this point in the history
  • Loading branch information
hildrum committed Oct 4, 2015
1 parent 0e14ee4 commit 10ea47c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions com.ibm.streamsx.inet/impl/cpp/src/httpFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ curl_free(result);
return toReturn;
}

CURLcode readResultAsRstring(CURL* curl , SPL::rstring & result) {
CURLcode readResultAsRstring(CURL* curl , SPL::rstring * resultPtr) {
// Now handle read, for error checking and exception handling
SPL::rstring toReturn;
CURLcode res = curl_easy_setopt(curl,CURLOPT_WRITEDATA,&result);
CURLcode res = curl_easy_setopt(curl,CURLOPT_WRITEDATA,resultPtr);
if (res != CURLE_OK) {
SPLAPPTRC(L_ERROR, "Error " << res << "setting data pointer", logTag);
return res;
Expand Down Expand Up @@ -223,15 +223,15 @@ size_t readFromRstring(char * buffer, size_t size, size_t nitems, void *instream
return i;
}

SPL::rstring httpDelete(const SPL::rstring & url, const SPL::list<SPL::rstring> &extraHeaders, const SPL::rstring & username, const SPL::rstring & password, SPL::list<SPL::rstring> & headers, SPL::int32 & error) {
SPL::rstring httpDelete(const SPL::rstring & url, const SPL::list<SPL::rstring> &extraHeaders, const SPL::rstring & username, const SPL::rstring & password, SPL::int32 & error) {

static __thread CURL* curlDelete = NULL;
error = 0;
if (curlDelete == NULL) {
curlDelete = curl_easy_init();
addCurlHandle(curlDelete);
}
headers.clear();

CURLcode res=addCommonOpts(curlDelete, url, extraHeaders, username, password);
if (res != CURLE_OK) {
error = res;
Expand All @@ -243,7 +243,7 @@ if (res != CURLE_OK) {
return "";
}
SPL::rstring toReturn;
res = readResultAsRstring(curlDelete,toReturn);
res = readResultAsRstring(curlDelete,&toReturn);
if (res != CURLE_OK) {
error = res;
return "";
Expand All @@ -253,6 +253,7 @@ if (res != CURLE_OK) {
error = res;
return "";
}
return toReturn;
}

SPL::rstring httpPost(const SPL::rstring & data, const SPL::rstring & url, const SPL::list<SPL::rstring> & extraHeaders, const SPL::rstring & username, const SPL::rstring & password, SPL::list<SPL::rstring> & headers,SPL::int32 & error) {
Expand Down Expand Up @@ -299,7 +300,7 @@ SPL::rstring httpPost(const SPL::rstring & data, const SPL::rstring & url, const

// Now handle read, for error checking and exception handling
SPL::rstring toReturn;
res = readResultAsRstring(curlPost,toReturn);
res = readResultAsRstring(curlPost,&toReturn);
if (res != CURLE_OK) {
error = res;
return "";
Expand Down Expand Up @@ -384,7 +385,7 @@ SPL::rstring httpPut(const SPL::rstring & data, const SPL::rstring & url, const
SPLAPPTRC(L_TRACE,"About to perform",logTag);
// Now handle read, for error checking and exception handling
SPL::rstring toReturn;
res = readResultAsRstring(curlPut,toReturn);
res = readResultAsRstring(curlPut,&toReturn);
if (res != CURLE_OK) {
error = res;
return "";
Expand Down Expand Up @@ -421,7 +422,7 @@ SPL::rstring httpGet(const SPL::rstring & url, const SPL::list<SPL::rstring> & e
error = res;
return toReturn;
}
res = readResultAsRstring(curlGet,toReturn);
res = readResultAsRstring(curlGet,&toReturn);

if (res != CURLE_OK) {
error = res;
Expand Down

0 comments on commit 10ea47c

Please sign in to comment.