diff --git a/gb.net.curl/src/CCurl.c b/gb.net.curl/src/CCurl.c index a56c0a7de..d38dc723c 100644 --- a/gb.net.curl/src/CCurl.c +++ b/gb.net.curl/src/CCurl.c @@ -253,13 +253,20 @@ void CURL_init_stream(void *_object) } +#define CHECK_PROGRESS_VAL(_var) if (THIS->_var != (int64_t)_var) { THIS->_var = (int64_t)_var; raise = TRUE; } + static int curl_progress(void *_object, double dltotal, double dlnow, double ultotal, double ulnow) { - THIS->dltotal = (int64_t)dltotal; - THIS->dlnow = (int64_t)dlnow; - THIS->ultotal = (int64_t)ultotal; - THIS->ulnow = (int64_t)ulnow; - GB.Raise(THIS, EVENT_Progress, 0); + bool raise = FALSE; + + CHECK_PROGRESS_VAL(dltotal); + CHECK_PROGRESS_VAL(dlnow); + CHECK_PROGRESS_VAL(ultotal); + CHECK_PROGRESS_VAL(ulnow); + + if (raise) + GB.Raise(THIS, EVENT_Progress, 0); + return 0; } @@ -379,6 +386,10 @@ bool CURL_check_active(void *_object) void CURL_set_progress(void *_object, bool progress) { + #ifdef DEBUG + fprintf(stderr, "CURL_set_progress: %p %d\n", _object, progress); + #endif + curl_easy_setopt(THIS_CURL, CURLOPT_NOPROGRESS, progress ? 0 : 1); if (progress) { diff --git a/gb.net.curl/src/CFtpClient.c b/gb.net.curl/src/CFtpClient.c index 17bae5a4f..106e1f164 100644 --- a/gb.net.curl/src/CFtpClient.c +++ b/gb.net.curl/src/CFtpClient.c @@ -149,7 +149,7 @@ static int ftp_exec(void *_object, int what, GB_ARRAY commands) curl_easy_setopt(THIS_CURL, CURLOPT_WRITEDATA , _object); curl_easy_setopt(THIS_CURL, CURLOPT_UPLOAD , 0); - CURL_set_progress(THIS_CURL, TRUE); + CURL_set_progress(THIS, TRUE); break; @@ -159,7 +159,7 @@ static int ftp_exec(void *_object, int what, GB_ARRAY commands) curl_easy_setopt(THIS_CURL, CURLOPT_READDATA , _object); curl_easy_setopt(THIS_CURL, CURLOPT_UPLOAD , 1); - CURL_set_progress(THIS_CURL, TRUE); + CURL_set_progress(THIS, TRUE); break; diff --git a/gb.net.curl/src/CHttpClient.c b/gb.net.curl/src/CHttpClient.c index 1035c9aea..1e207fb46 100644 --- a/gb.net.curl/src/CHttpClient.c +++ b/gb.net.curl/src/CHttpClient.c @@ -209,10 +209,10 @@ static void http_initialize_curl_handle(void *_object, GB_ARRAY custom_headers) else curl_easy_setopt(THIS_CURL, CURLOPT_COOKIEJAR, NULL); - CURL_proxy_set(&THIS->proxy.proxy,THIS_CURL); + CURL_proxy_set(&THIS->proxy.proxy, THIS_CURL); CURL_user_set(&THIS->user, THIS_CURL); - curl_easy_setopt(THIS_CURL, CURLOPT_URL,THIS_URL); - + curl_easy_setopt(THIS_CURL, CURLOPT_URL, THIS_URL); + THIS_HTTP->return_code = 0; GB.FreeString(&THIS_HTTP->return_string); @@ -301,7 +301,7 @@ static void http_get(void *_object, GB_ARRAY custom_headers, char *target) } curl_easy_setopt(THIS_CURL, CURLOPT_HTTPHEADER, headers); - CURL_set_progress(THIS_CURL, TRUE); + CURL_set_progress(THIS, TRUE); if (THIS->async) { @@ -309,7 +309,7 @@ static void http_get(void *_object, GB_ARRAY custom_headers, char *target) return; } - CURL_manage_error(_object,curl_easy_perform(THIS_CURL)); + CURL_manage_error(_object, curl_easy_perform(THIS_CURL)); }