[GB.NET.CURL]

* NEW: HttpClient Progress event is raised now.
* BUG: FtpClient and HttpClient Progress event work as expected now.


git-svn-id: svn://localhost/gambas/trunk@5675 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-05-24 22:23:22 +00:00
parent 1da147d6e5
commit 4e5099500a
3 changed files with 23 additions and 12 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -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));
}