--- parser3/src/classes/curl.C 2012/04/22 20:03:02 1.18 +++ parser3/src/classes/curl.C 2012/06/15 06:13:10 1.21 @@ -16,7 +16,7 @@ #include "pa_http.h" #include "ltdl.h" -volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.18 2012/04/22 20:03:02 moko Exp $"; +volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.21 2012/06/15 06:13:10 misha Exp $"; class MCurl: public Methoded { public: @@ -76,13 +76,13 @@ public: bool is_text; Charset *charset, *response_charset; struct curl_httppost *f_post; - FILE *stderr; + FILE *f_stderr; - ParserOptions() : filename(0), content_type(0), is_text(true), charset(0), response_charset(0), f_post(0), stderr(0){} + ParserOptions() : filename(0), content_type(0), is_text(true), charset(0), response_charset(0), f_post(0), f_stderr(0){} ~ParserOptions() { f_curl_formfree(f_post); - if(stderr) - fclose(stderr); + if(f_stderr) + fclose(f_stderr); } }; @@ -442,9 +442,9 @@ static void curl_setopt(HashStringValue: case CurlOption::CURL_STDERR:{ // verbose output redirection from stderr to file curl option const char *file_spec_cstr=curl_check_file(r.absolute(v.as_string())); - FILE *stderr=options().stderr=fopen(file_spec_cstr, "wt"); - if (stderr){ - res=f_curl_easy_setopt(curl(), opt->id, stderr); + FILE *f_stderr=options().f_stderr=fopen(file_spec_cstr, "wt"); + if (f_stderr){ + res=f_curl_easy_setopt(curl(), opt->id, f_stderr); } else { throw Exception("curl", 0, "failed to set option '%s': unable to open file '%s'", key.cstr(), file_spec_cstr); } @@ -493,10 +493,8 @@ static void _curl_options(Request& r, Me if(curl_options==0) curl_options=new CurlOptionHash(); - if(HashStringValue* options=params.as_no_junction(0, OPTIONS_MUST_NOT_BE_CODE).get_hash()){ + if(HashStringValue* options=params.as_hash(0)) options->for_each(curl_setopt, r); - } else - throw Exception("curl", 0, OPTIONS_MUST_BE_HASH); } @@ -600,11 +598,9 @@ static void _curl_load_action(Request& r body.length=c.length; } - result.set(true /*tainted*/, body.buf, body.length, options().filename + result.set(true/*tainted*/, options().is_text, body.buf, body.length, options().filename , options().content_type ? new VString(*options().content_type) : 0 , &r); - result.set_mode(options().is_text); - long http_status = 0; if(f_curl_easy_getinfo(curl(), CURLINFO_RESPONSE_CODE, &http_status) == CURLE_OK){ result.fields().put("status", new VInt(http_status));