--- parser3/src/classes/curl.C 2015/10/09 15:43:52 1.32 +++ parser3/src/classes/curl.C 2015/10/26 01:21:53 1.35 @@ -1,7 +1,7 @@ /** @file Parser: @b curl parser class. - Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) */ #include "pa_config_includes.h" @@ -17,7 +17,7 @@ #include "pa_http.h" #include "ltdl.h" -volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.32 2015/10/09 15:43:52 moko Exp $"; +volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.35 2015/10/26 01:21:53 moko Exp $"; class MCurl: public Methoded { public: @@ -556,10 +556,8 @@ static void _curl_options(Request& r, Me throw Exception("curl", 0, "failed to get %s info: %s", key.cstr(), f_curl_easy_strerror(res)); \ } -static Value *curl_getinfo(const String::Body &key) { - CurlInfo *info=curl_infos->get(key); - - if(info==0) +static Value *curl_getinfo(const String::Body &key, CurlInfo *info=0) { + if(info==0 && !(info=curl_infos->get(key))) throw Exception("curl", 0, "called with invalid parameter '%s'", key.cstr()); CURLcode res; @@ -567,7 +565,7 @@ static Value *curl_getinfo(const String: case CurlInfo::CURL_STRING:{ char *str=0; CURL_GETINFO(str); - return new VString(*new String(str, String::L_TAINTED)); + return new VString(str ? *new String(pa_strdup(str), String::L_TAINTED) : String::Empty); } case CurlInfo::CURL_INT:{ long l=0; @@ -592,7 +590,7 @@ static void _curl_info(Request& r, Metho } else { VHash& result=*new VHash; for(CurlInfoHash::Iterator i(*curl_infos); i; i.next() ){ - result.get_hash()->put(i.key(), curl_getinfo(i.key())); + result.get_hash()->put(i.key(), curl_getinfo(i.key(), i.value())); } r.write_no_lang(result); }