@@ -43,16 +43,12 @@ my_bool send_post_deinit(UDF_INIT *initid, UDF_ARGS *args, char *message)
4343
4444long long send_post (UDF_INIT * initid , UDF_ARGS * args , char * is_null , char * error )
4545{
46- CURLcode code = 1 ;
46+ long long code = 0 ;
4747 char method [] = "POST" ;
4848 if (wrapup_request (args , method , & code ))
4949 {
5050 * error = 1 ;
5151 }
52- if (code )
53- {
54- * error = 1 ;
55- }
5652 return code ;
5753}
5854
@@ -68,16 +64,12 @@ my_bool send_put_deinit(UDF_INIT *initid, UDF_ARGS *args, char *message)
6864
6965long long send_put (UDF_INIT * initid , UDF_ARGS * args , char * is_null , char * error )
7066{
71- CURLcode code = 1 ;
67+ long long code = 0 ;
7268 char method [] = "PUT" ;
7369 if (wrapup_request (args , method , & code ))
7470 {
7571 * error = 1 ;
7672 }
77- if (code )
78- {
79- * error = 1 ;
80- }
8173 return code ;
8274}
8375
@@ -93,16 +85,12 @@ my_bool send_delete_deinit(UDF_INIT *initid, UDF_ARGS *args, char *message)
9385
9486long long send_delete (UDF_INIT * initid , UDF_ARGS * args , char * is_null , char * error )
9587{
96- CURLcode code = 1 ;
88+ long long code = 0 ;
9789 char method [] = "DELETE" ;
9890 if (wrapup_request (args , method , & code ))
9991 {
10092 * error = 1 ;
10193 }
102- if (code )
103- {
104- * error = 1 ;
105- }
10694 return code ;
10795}
10896
@@ -213,7 +201,7 @@ void encapsulate_data(UDF_ARGS* udf_args, char** res_str)
213201 (* res_str )[res_len + 2 ] = '\0' ;
214202}
215203
216- int wrapup_request (UDF_ARGS * args , const char * method , CURLcode * code )
204+ int wrapup_request (UDF_ARGS * args , const char * method , long long * response_code )
217205{
218206 curl_global_init (CURL_GLOBAL_ALL );
219207 CURL * handle = curl_easy_init ();
@@ -234,7 +222,11 @@ int wrapup_request(UDF_ARGS *args, const char *method, CURLcode *code)
234222 {
235223 return 1 ;
236224 }
237- * code = curl_easy_perform (handle );
225+ if (curl_easy_perform (handle ))
226+ {
227+ return 1 ;
228+ }
229+ curl_easy_getinfo (handle , CURLINFO_RESPONSE_CODE , response_code );
238230 curl_global_cleanup ();
239231 return 0 ;
240232}
0 commit comments