[GB.NET.CURL]
* NEW: FtpClient: BufferSize is a new property that allows to define the receive buffer size. * NEW: HttpClient: BufferSize is a new property that allows to define the receive buffer size. git-svn-id: svn://localhost/gambas/trunk@8144 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
32402ceb9a
commit
04cf87720c
4 changed files with 48 additions and 19 deletions
|
@ -260,8 +260,20 @@ void CURL_init_stream(void *_object)
|
|||
|
||||
void CURL_init_options(void *_object)
|
||||
{
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_TIMEOUT, THIS->timeout);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_VERBOSE, (bool)THIS->debug);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_PRIVATE, (char*)_object);
|
||||
|
||||
if (THIS->buffer_size)
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_BUFFERSIZE, THIS->buffer_size);
|
||||
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_SSL_VERIFYPEER, THIS->ssl_verify_peer ? 1 : 0);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_SSL_VERIFYHOST , THIS->ssl_verify_host ? 2 : 0);
|
||||
|
||||
CURL_proxy_set(&THIS->proxy.proxy, THIS_CURL);
|
||||
CURL_user_set(&THIS->user, THIS_CURL);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_URL, THIS_URL);
|
||||
}
|
||||
|
||||
#define CHECK_PROGRESS_VAL(_var) if (THIS->_var != (int64_t)_var) { THIS->_var = (int64_t)_var; raise = TRUE; }
|
||||
|
@ -426,6 +438,7 @@ bool CURL_copy_from(CCURL *dest, CCURL *src)
|
|||
dest->async = src->async;
|
||||
dest->timeout = src->timeout;
|
||||
dest->debug = src->debug;
|
||||
dest->buffer_size = src->buffer_size;
|
||||
COPY_STRING(url);
|
||||
|
||||
dest->user.auth = src->user.auth;
|
||||
|
@ -497,6 +510,31 @@ BEGIN_PROPERTY(Curl_Timeout)
|
|||
END_PROPERTY
|
||||
|
||||
|
||||
BEGIN_PROPERTY(Curl_BufferSize)
|
||||
|
||||
if (READ_PROPERTY)
|
||||
GB.ReturnInteger(THIS->buffer_size);
|
||||
else
|
||||
{
|
||||
int buffer_size;
|
||||
|
||||
if (CURL_check_active(THIS))
|
||||
return;
|
||||
|
||||
buffer_size = VPROP(GB_INTEGER);
|
||||
if (buffer_size <= 0)
|
||||
buffer_size = 0;
|
||||
else if (buffer_size < 1024)
|
||||
buffer_size = 1024;
|
||||
else if (buffer_size > CURL_MAX_READ_SIZE)
|
||||
buffer_size = CURL_MAX_READ_SIZE;
|
||||
|
||||
THIS->buffer_size = buffer_size;
|
||||
}
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
|
||||
BEGIN_PROPERTY(Curl_Password)
|
||||
|
||||
if (READ_PROPERTY)
|
||||
|
@ -594,7 +632,7 @@ BEGIN_METHOD_VOID(Curl_new)
|
|||
THIS->ssl_verify_host = TRUE;
|
||||
|
||||
THIS->proxy.parent_status = (int*)&THIS_STATUS;
|
||||
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD_VOID(Curl_free)
|
||||
|
@ -745,6 +783,7 @@ GB_DESC CurlDesc[] =
|
|||
GB_PROPERTY_READ("Status", "i", Curl_Status),
|
||||
GB_PROPERTY_READ("ErrorText", "s", Curl_ErrorText),
|
||||
GB_PROPERTY("Debug", "b", Curl_Debug),
|
||||
GB_PROPERTY("BufferSize", "i", Curl_BufferSize),
|
||||
|
||||
GB_PROPERTY_READ("Downloaded", "l", Curl_Downloaded),
|
||||
GB_PROPERTY_READ("Uploaded", "l", Curl_Uploaded),
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
#ifndef CURL_MAX_READ_SIZE
|
||||
#define CURL_MAX_READ_SIZE 524288
|
||||
#endif
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
#ifndef __CCURL_C
|
||||
|
@ -70,6 +74,7 @@ typedef
|
|||
CPROXY proxy;
|
||||
CURL_USER user;
|
||||
int timeout;
|
||||
int buffer_size;
|
||||
int method; // 0->Get, 1->Put
|
||||
char *data;
|
||||
int64_t dltotal;
|
||||
|
|
|
@ -110,21 +110,13 @@ static void ftp_initialize_curl_handle(void *_object)
|
|||
#endif
|
||||
}
|
||||
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_TIMEOUT, THIS->timeout);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_VERBOSE, (bool)THIS->debug);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_PRIVATE,(char*)_object);
|
||||
|
||||
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_init_options(THIS);
|
||||
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_FTP_USE_EPSV, (long)(THIS_FTP->no_epsv ? 0 : 1));
|
||||
|
||||
ftp_reset(THIS_FTP);
|
||||
THIS_STATUS = NET_CONNECTING;
|
||||
|
||||
CURL_init_options(THIS);
|
||||
CURL_init_stream(THIS);
|
||||
}
|
||||
|
||||
|
|
|
@ -195,10 +195,8 @@ static void http_initialize_curl_handle(void *_object, GB_ARRAY custom_headers)
|
|||
THIS_CURL = curl_easy_init();
|
||||
}
|
||||
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_NOSIGNAL,1);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_TIMEOUT,THIS->timeout);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_VERBOSE, (bool)THIS->debug);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_PRIVATE,(char*)_object);
|
||||
CURL_init_options(THIS);
|
||||
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_USERAGENT, THIS_HTTP->sUserAgent);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_ENCODING, THIS_HTTP->encoding);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_HEADERFUNCTION, (curl_write_callback)http_header_curl);
|
||||
|
@ -212,10 +210,6 @@ 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_user_set(&THIS->user, THIS_CURL);
|
||||
curl_easy_setopt(THIS_CURL, CURLOPT_URL, THIS_URL);
|
||||
|
||||
THIS_HTTP->return_code = 0;
|
||||
GB.FreeString(&THIS_HTTP->return_string);
|
||||
|
||||
|
@ -229,7 +223,6 @@ static void http_initialize_curl_handle(void *_object, GB_ARRAY custom_headers)
|
|||
GB.Ref(custom_headers);
|
||||
}
|
||||
|
||||
CURL_init_options(THIS);
|
||||
CURL_init_stream(THIS);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue