#include <curl/curl.h>
#include "kds_s2000w_client.h"
-int _wait = 0;
-
-void _kds_s2000w_client_wait_for_response()
-{
- for (int i = 0; i < 10; i++) {
- if (!_wait)
- break;
-
- sleep(1);
- }
-}
-
size_t _kds_s2000w_client_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
{
response* data = (response*) userdata;
memcpy(data->data, ptr, fullsize);
data->size = fullsize + 1;
- _wait = 0;
return fullsize;
}
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) response);
- _wait = 1;
CURLcode result = curl_easy_perform(curl);
- _kds_s2000w_client_wait_for_response();
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code);
+ if (response->code == 408) {
+ sleep(1);
+ CURLcode result = curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code);
+ }
+
curl_url_cleanup(url_handler);
url_handler = NULL;
curl_free(url);