--- parser3/src/classes/curl.C 2013/04/21 21:24:53 1.26 +++ parser3/src/classes/curl.C 2015/04/08 18:08:52 1.31 @@ -16,7 +16,7 @@ #include "pa_http.h" #include "ltdl.h" -volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.26 2013/04/21 21:24:53 moko Exp $"; +volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.31 2015/04/08 18:08:52 moko Exp $"; class MCurl: public Methoded { public: @@ -44,8 +44,7 @@ typedef void (*t_curl_formfree)(struct c #define DLINK(name) GLINK(name) if(!f_##name) return "function " #name " was not found"; static const char *dlink(const char *dlopen_file_spec) { - if(lt_dlinit()) - return lt_dlerror(); + pa_dlinit(); lt_dlhandle handle=lt_dlopen(dlopen_file_spec); @@ -112,6 +111,7 @@ public: fcurl = f_curl_easy_init(); foptions = new ParserOptions(); f_curl_easy_setopt(fcurl, CURLOPT_POSTFIELDSIZE, 0); // fix libcurl bug + f_curl_easy_setopt(fcurl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // avoid ipv6 by default } ~Temp_curl() { f_curl_easy_cleanup(fcurl); @@ -122,11 +122,7 @@ public: }; bool curl_linked = false; -#ifdef WIN32 -const char *curl_library="libcurl.dll"; -#else -const char *curl_library="libcurl.so"; -#endif +const char *curl_library="libcurl" LT_MODULE_EXT; const char *curl_status = 0; @@ -230,6 +226,7 @@ public: CURL_OPT(CURL_INT, FOLLOWLOCATION); CURL_OPT(CURL_INT, UNRESTRICTED_AUTH); + CURL_OPT(CURL_INT, IPRESOLVE); CURL_OPT(CURL_INT, POST); CURL_OPT(CURL_INT, HTTPGET); @@ -477,8 +474,7 @@ static void curl_setopt(HashStringValue: break; } case CurlOption::PARSER_CHARSET:{ - // 'charset' parser option - options().charset=&::charsets.get(v.as_string().change_case(r.charsets.source(), String::CC_UPPER)); + // 'charset' parser option should be processed before other options break; } case CurlOption::PARSER_RESPONSE_CHARSET:{ @@ -496,8 +492,14 @@ static void _curl_options(Request& r, Me if(curl_options==0) curl_options=new CurlOptionHash(); - if(HashStringValue* options=params.as_hash(0)) - options->for_each(curl_setopt, r); + if(HashStringValue* options_hash=params.as_hash(0)){ + if(Value* value=options_hash->get("charset")){ + // charset should be handled first as params may require transcode + Value &v=r.process_to_value(*value); + options().charset=&::charsets.get(v.as_string().change_case(r.charsets.source(), String::CC_UPPER)); + } + options_hash->for_each(curl_setopt, r); + } } @@ -588,6 +590,7 @@ static void _curl_load_action(Request& r case CURLE_SSL_CACERT: case CURLE_SSL_ENGINE_INITFAILED: ex_type = "curl.ssl"; break; + default: break; } throw Exception( ex_type ? ex_type : "curl.fail", 0, "%s", f_curl_easy_strerror(res)); }