@@ -43,16 +43,12 @@ my_bool send_post_deinit(UDF_INIT *initid, UDF_ARGS *args, char *message)
43
43
44
44
long long send_post (UDF_INIT * initid , UDF_ARGS * args , char * is_null , char * error )
45
45
{
46
- CURLcode code = 1 ;
46
+ long long code = 0 ;
47
47
char method [] = "POST" ;
48
48
if (wrapup_request (args , method , & code ))
49
49
{
50
50
* error = 1 ;
51
51
}
52
- if (code )
53
- {
54
- * error = 1 ;
55
- }
56
52
return code ;
57
53
}
58
54
@@ -68,16 +64,12 @@ my_bool send_put_deinit(UDF_INIT *initid, UDF_ARGS *args, char *message)
68
64
69
65
long long send_put (UDF_INIT * initid , UDF_ARGS * args , char * is_null , char * error )
70
66
{
71
- CURLcode code = 1 ;
67
+ long long code = 0 ;
72
68
char method [] = "PUT" ;
73
69
if (wrapup_request (args , method , & code ))
74
70
{
75
71
* error = 1 ;
76
72
}
77
- if (code )
78
- {
79
- * error = 1 ;
80
- }
81
73
return code ;
82
74
}
83
75
@@ -93,16 +85,12 @@ my_bool send_delete_deinit(UDF_INIT *initid, UDF_ARGS *args, char *message)
93
85
94
86
long long send_delete (UDF_INIT * initid , UDF_ARGS * args , char * is_null , char * error )
95
87
{
96
- CURLcode code = 1 ;
88
+ long long code = 0 ;
97
89
char method [] = "DELETE" ;
98
90
if (wrapup_request (args , method , & code ))
99
91
{
100
92
* error = 1 ;
101
93
}
102
- if (code )
103
- {
104
- * error = 1 ;
105
- }
106
94
return code ;
107
95
}
108
96
@@ -213,7 +201,7 @@ void encapsulate_data(UDF_ARGS* udf_args, char** res_str)
213
201
(* res_str )[res_len + 2 ] = '\0' ;
214
202
}
215
203
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 )
217
205
{
218
206
curl_global_init (CURL_GLOBAL_ALL );
219
207
CURL * handle = curl_easy_init ();
@@ -234,7 +222,11 @@ int wrapup_request(UDF_ARGS *args, const char *method, CURLcode *code)
234
222
{
235
223
return 1 ;
236
224
}
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 );
238
230
curl_global_cleanup ();
239
231
return 0 ;
240
232
}
0 commit comments