diff options
author | Dirk Völzke <dv@openoffice.org> | 2009-09-25 11:13:49 +0000 |
---|---|---|
committer | Dirk Völzke <dv@openoffice.org> | 2009-09-25 11:13:49 +0000 |
commit | 9a57c3de06263eeaa28a4644d53248bdfca6df0f (patch) | |
tree | 8872207d8fee14047f955f7ee6cb377bc46b6f84 /extensions/source/update | |
parent | 4496e7dc73caf6070ccf7d4a170cbdbbefa0d817 (diff) |
#i88957# Handle some http errors
Diffstat (limited to 'extensions/source/update')
-rw-r--r-- | extensions/source/update/check/download.cxx | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 8c64c037da7e..1d50ddad7305 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -267,6 +267,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx rtl::OString aURL(rtl::OUStringToOString(rURL, RTL_TEXTENCODING_UTF8)); curl_easy_setopt(pCURL, CURLOPT_URL, aURL.getStr()); + // abort on http errors + curl_easy_setopt(pCURL, CURLOPT_FAILONERROR, 1); + // enable redirection curl_easy_setopt(pCURL, CURLOPT_FOLLOWLOCATION, 1); @@ -318,7 +321,30 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx if( NULL != error_message ) aMessage = error_message; - out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) ); + if ( CURLE_HTTP_RETURNED_ERROR == cc ) + { + long nError; + curl_easy_getinfo( pCURL, CURLINFO_RESPONSE_CODE, &nError ); + + if ( 403 == nError ) + aMessage += RTL_CONSTASCII_STRINGPARAM( " 403: Access denied!" ); + else if ( 404 == nError ) + aMessage += RTL_CONSTASCII_STRINGPARAM( " 404: File not found!" ); + else if ( 416 == nError ) + { + // we got this error probably, because we already downloaded the file + out.Handler->downloadFinished(out.File); + ret = true; + } + else + { + aMessage += RTL_CONSTASCII_STRINGPARAM( ":error code = " ); + aMessage += aMessage.valueOf( nError ); + aMessage += RTL_CONSTASCII_STRINGPARAM( " !" ); + } + } + if ( !ret ) + out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) ); } curl_easy_cleanup(pCURL); |