--- parser3/src/classes/curl.C 2009/12/04 04:20:34 1.1 +++ parser3/src/classes/curl.C 2009/12/22 04:47:19 1.3 @@ -4,7 +4,11 @@ Copyright(c) 2001-2009 ArtLebedev Group(http://www.artlebedev.com) */ -static const char * const IDENT_INET_C="$Date: 2009/12/04 04:20:34 $"; +#include "pa_config_includes.h" + +#ifdef HAVE_CURL + +static const char * const IDENT_INET_C="$Date: 2009/12/22 04:47:19 $"; #include "pa_vmethod_frame.h" #include "pa_request.h" @@ -27,7 +31,6 @@ DECLARE_CLASS_VAR(curl, new MCurl, 0); // from file.C extern bool is_text_mode(const String& mode); -#ifdef HAVE_CURL #include "curl.h" typedef CURL *(*t_curl_easy_init)(); t_curl_easy_init f_curl_easy_init; @@ -191,8 +194,10 @@ public: CURL_OPT(CURL_INT, HTTPAUTH); CURL_OPT(CURL_STRING, USERPWD); +#ifdef CURLOPT_USERNAME CURL_OPT(CURL_STRING, USERNAME); CURL_OPT(CURL_STRING, PASSWORD); +#endif CURL_OPT(CURL_INT, AUTOREFERER); CURL_OPT(CURL_STRING, ENCODING); // gzip or deflate @@ -233,8 +238,13 @@ public: CURL_OPT(CURL_STRING, SSLENGINE); CURL_OPT(CURL_STRING, SSLENGINE_DEFAULT); +#ifdef CURLOPT_ISSUERCERT CURL_OPT(CURL_FILE, ISSUERCERT); +#endif + +#ifdef CURLOPT_CRLFILE CURL_OPT(CURL_FILE, CRLFILE); +#endif CURL_OPT(CURL_STRING, CAINFO); CURL_OPT(CURL_STRING, CAPATH); @@ -297,19 +307,19 @@ static void curl_setopt(HashStringValue: break; } case CurlOption::CURL_INT:{ - // int curl option - int value_int=(int)v.as_double(); + // integer curl option + long value_int=(long)v.as_double(); res=f_curl_easy_setopt(curl(), opt->id, value_int); break; } case CurlOption::CURL_POST:{ // http post curl option if(v.get_string()){ - if( (res=f_curl_easy_setopt(curl(), CURLOPT_POSTFIELDSIZE, -1)) == CURLE_OK ) + if( (res=f_curl_easy_setopt(curl(), CURLOPT_POSTFIELDSIZE, -1L)) == CURLE_OK ) res=f_curl_easy_setopt(curl(), opt->id, curl_urlencode(v.as_string(), r)); } else { VFile *file=v.as_vfile(String::L_AS_IS); - if( (res=f_curl_easy_setopt(curl(), CURLOPT_POSTFIELDSIZE, file->value_size())) == CURLE_OK ) + if( (res=f_curl_easy_setopt(curl(), CURLOPT_POSTFIELDSIZE, (long)file->value_size())) == CURLE_OK ) res=f_curl_easy_setopt(curl(), opt->id, file->value_ptr()); } break; @@ -360,7 +370,7 @@ static void curl_setopt(HashStringValue: throw Exception("curl", 0, "failed to set option '%s': %s", key.cstr(), f_curl_easy_strerror(res)); } -static void _curl_option(Request& r, MethodParams& params){ +static void _curl_options(Request& r, MethodParams& params){ if(curl_options==0) curl_options=new CurlOptionHash(); @@ -419,7 +429,7 @@ static int curl_header(char *data, size_ static void _curl_load_action(Request& r, MethodParams& params){ if(params.count()==1) - _curl_option(r, params); + _curl_options(r, params); CURLcode res; @@ -472,13 +482,17 @@ static void _curl_load(Request& r, Metho fcurl ? _curl_load_action(r, params) : temp_curl(_curl_load_action, r, params); } -#endif // HAVE_CURL - // constructor MCurl::MCurl(): Methoded("curl") { -#ifdef HAVE_CURL add_native_method("session", Method::CT_STATIC, _curl_session, 1, 1); - add_native_method("option", Method::CT_STATIC, _curl_option, 1, 1); + add_native_method("options", Method::CT_STATIC, _curl_options, 1, 1); add_native_method("load", Method::CT_STATIC, _curl_load, 0, 1); -#endif // HAVE_CURL } + +#else // HAVE_CURL + +#include "classes.h" +// global variable +DECLARE_CLASS_VAR(curl, 0, 0); // fictive + +#endif // HAVE_CURL