Mercurial > octave-nkf
diff src/DLD-FUNCTIONS/urlwrite.cc @ 12963:27e5f0e79f19
Return better error codes from curl, even if connection is successful
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Sun, 14 Aug 2011 21:17:12 -0500 |
parents | 9d5e468befe5 |
children | a33ec41d0340 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/urlwrite.cc Sun Aug 14 12:41:20 2011 -0500 +++ b/src/DLD-FUNCTIONS/urlwrite.cc Sun Aug 14 21:17:12 2011 -0500 @@ -112,11 +112,11 @@ { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; - CURLcode res = curl_easy_perform (curl); - if (res != CURLE_OK) + errnum = curl_easy_perform (curl); + if (errnum != CURLE_OK) { if (curlerror) - error ("%s", curl_easy_strerror (res)); + error ("%s", curl_easy_strerror (errnum)); } else retval = true; @@ -145,6 +145,7 @@ std::string host; bool valid; bool ascii; + mutable CURLcode errnum; private: CURL *curl; @@ -250,11 +251,7 @@ std::string lasterror (void) const { - CURLcode errnum; - - curl_easy_getinfo (rep->handle(), CURLINFO_OS_ERRNO, &errnum); - - return std::string (curl_easy_strerror (errnum)); + return std::string (curl_easy_strerror (rep->errnum)); } void set_ostream (std::ostream& os) const