--- parser3/src/classes/curl.C 2019/01/15 13:57:38 1.61 +++ parser3/src/classes/curl.C 2020/10/14 21:20:15 1.63 @@ -17,7 +17,7 @@ #include "pa_http.h" #include "ltdl.h" -volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.61 2019/01/15 13:57:38 moko Exp $"; +volatile const char * IDENT_CURL_C="$Id: curl.C,v 1.63 2020/10/14 21:20:15 moko Exp $"; class MCurl: public Methoded { public: @@ -655,9 +655,9 @@ public: char *buf; size_t length; size_t buf_size; - ResponseHeaders& headers; + HTTP_Headers& headers; - Curl_buffer(ResponseHeaders& aheaders) : buf((char *)pa_malloc_atomic(MAX_STRING)), length(0), buf_size(MAX_STRING-1), headers(aheaders){} + Curl_buffer(HTTP_Headers& aheaders) : buf((char *)pa_malloc_atomic(MAX_STRING)), length(0), buf_size(MAX_STRING-1), headers(aheaders){} void resize(size_t size){ buf_size=size; @@ -680,7 +680,7 @@ static int curl_writer(char *data, size_ return size; } -static int curl_header(char *data, size_t size, size_t nmemb, ResponseHeaders *result){ +static int curl_header(char *data, size_t size, size_t nmemb, HTTP_Headers *result){ if(result == 0) return 0; @@ -711,7 +711,7 @@ static void _curl_load_action(Request& r CURLcode res; // we need a container for headers as VFile fields can be put only after VFile.set - ResponseHeaders response; + HTTP_Headers response; CURL_SETOPT(CURLOPT_HEADERFUNCTION, curl_header, "curl header function"); CURL_SETOPT(CURLOPT_WRITEHEADER, &response, "curl header buffer"); @@ -725,7 +725,8 @@ static void _curl_load_action(Request& r CURL_SETOPT(CURLOPT_POSTFIELDSIZE, 0, "post content-length"); } - if((res=f_curl_easy_perform(curl())) != CURLE_OK){ + ALTER_EXCEPTION_SOURCE(res=f_curl_easy_perform(curl()), new String(options().url)); + if(res != CURLE_OK){ const char *ex_type = 0; switch(res){ case CURLE_OPERATION_TIMEDOUT: @@ -746,7 +747,7 @@ static void _curl_load_action(Request& r check_file_size(response.content_length, *new String(options().url)); break; default: break; } - throw Exception( PA_DEFAULT(ex_type, "curl.fail"), 0, "%s", f_curl_easy_strerror(res)); + throw Exception( PA_DEFAULT(ex_type, "curl.fail"), new String(options().url), "%s", f_curl_easy_strerror(res)); } // assure trailing zero @@ -783,8 +784,8 @@ static void _curl_load_action(Request& r VHash* vtables=new VHash; result.fields().put("tables", vtables); - for(Array_iterator i(response.headers); i.has_next(); ){ - ResponseHeaders::Header header=i.next(); + for(Array_iterator i(response.headers); i.has_next(); ){ + HTTP_Headers::Header header=i.next(); if(asked_charset) header.transcode(*asked_charset, r.charsets.source());