[GB.NET.CURL]

* NEW: Curl.SSL.VerifyPeer and Curl.SSL.VerifyHost are two new properties 
  that allow to define the corresponding options of a CURL connection.


git-svn-id: svn://localhost/gambas/trunk@5771 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-08-04 12:03:48 +00:00
parent c9ca5ab982
commit 99385dca5d
3 changed files with 50 additions and 7 deletions

View file

@ -545,7 +545,10 @@ BEGIN_METHOD_VOID(Curl_new)
CURL_user_init(&THIS->user);
CURL_proxy_init(&THIS->proxy.proxy);
THIS->ssl_verify_peer = TRUE;
THIS->ssl_verify_host = TRUE;
THIS->proxy.parent_status = (int*)&THIS_STATUS;
END_METHOD
@ -637,10 +640,45 @@ BEGIN_PROPERTY(Curl_TotalUploaded)
END_PROPERTY
//*************************************************************************
//#################### GAMBAS INTERFACE ###################################
//*************************************************************************
GB_DESC CCurlDesc[] =
//---------------------------------------------------------------------------
BEGIN_PROPERTY(Curl_SSL_VerifyPeer)
if (READ_PROPERTY)
GB.ReturnBoolean(THIS->ssl_verify_peer);
else
{
THIS->ssl_verify_peer = VPROP(GB_BOOLEAN);
curl_easy_setopt(THIS_CURL, CURLOPT_SSL_VERIFYPEER, THIS->ssl_verify_peer ? 1 : 0);
}
END_PROPERTY
BEGIN_PROPERTY(Curl_SSL_VerifyHost)
if (READ_PROPERTY)
GB.ReturnBoolean(THIS->ssl_verify_host);
else
{
THIS->ssl_verify_host = VPROP(GB_BOOLEAN);
curl_easy_setopt(THIS_CURL, CURLOPT_SSL_VERIFYHOST , THIS->ssl_verify_host ? 2 : 0);
}
END_PROPERTY
//---------------------------------------------------------------------------
GB_DESC CurlSSLDesc[] =
{
GB_DECLARE_VIRTUAL(".Curl.SSL"),
GB_PROPERTY("VerifyPeer", "b", Curl_SSL_VerifyPeer),
GB_PROPERTY("VerifyHost", "b", Curl_SSL_VerifyHost),
GB_END_DECLARE
};
GB_DESC CurlDesc[] =
{
GB_DECLARE("Curl", sizeof(CCURL)), GB_NOT_CREATABLE(),
@ -659,6 +697,7 @@ GB_DESC CCurlDesc[] =
GB_PROPERTY("Async", "b", Curl_Async),
GB_PROPERTY("Timeout", "i", Curl_Timeout),
GB_PROPERTY_SELF("Proxy", ".Curl.Proxy"),
GB_PROPERTY_SELF("SSL", ".Curl.SSL"),
GB_PROPERTY_READ("Status", "i", Curl_Status),
GB_PROPERTY_READ("ErrorText", "s", Curl_ErrorText),
GB_PROPERTY("Debug", "b", Curl_Debug),

View file

@ -36,7 +36,8 @@
#ifndef __CCURL_C
extern GB_DESC CCurlDesc[];
extern GB_DESC CurlDesc[];
extern GB_DESC CurlSSLDesc[];
extern GB_STREAM_DESC CurlStream;
#endif
@ -75,6 +76,8 @@ typedef
unsigned async : 1;
unsigned in_list : 1;
unsigned debug : 1;
unsigned ssl_verify_peer : 1;
unsigned ssl_verify_host : 1;
}
CCURL;

View file

@ -40,7 +40,8 @@ GB_DESC *GB_CLASSES[] EXPORT =
{
CNetDesc,
CProxyDesc,
CCurlDesc,
CurlSSLDesc,
CurlDesc,
CHttpClientDesc,
CFtpClientDesc,
NULL