diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-10-11 20:39:39 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-01 18:48:58 +0100 |
commit | b3fc6caf392809d844e84f6a36db6a0fe3111c39 (patch) | |
tree | cf6a3d1d31734244f6a166ecc53f4aab383f8996 /ucb | |
parent | 2785402a4b47cb4d5764d0ad9f1554b579a9e5d2 (diff) |
ucb: webdav-curl: tdf#102499 (2): Refactor the WebDAV resource access retry
[ port of commit ac060f97cc937787b4079e435c5b312f6894c277 ]
Change-Id: Ib8cb79ddc67a486b067d3187a965ac55ae698fa4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123492
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVException.hxx | 4 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx | 42 |
2 files changed, 29 insertions, 17 deletions
diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx b/ucb/source/ucp/webdav-curl/DAVException.hxx index ba121efa21c9..4da64420cc00 100644 --- a/ucb/source/ucp/webdav-curl/DAVException.hxx +++ b/ucb/source/ucp/webdav-curl/DAVException.hxx @@ -81,14 +81,14 @@ const sal_uInt16 SC_UNPROCESSABLE_ENTITY = 422; const sal_uInt16 SC_LOCKED = 423; const sal_uInt16 SC_FAILED_DEPENDENCY = 424; -//5xx (Server error) +//5xx (Server error, general <https://tools.ietf.org/html/rfc7231#section-6.6>) const sal_uInt16 SC_INTERNAL_SERVER_ERROR = 500; const sal_uInt16 SC_NOT_IMPLEMENTED = 501; const sal_uInt16 SC_BAD_GATEWAY = 502; const sal_uInt16 SC_SERVICE_UNAVAILABLE = 503; const sal_uInt16 SC_GATEWAY_TIMEOUT = 504; const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED = 505; -// DAV extensions +// DAV extensions (<https://tools.ietf.org/html/rfc4918#section-11>) const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507; diff --git a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx index cead9980b4a6..e76e6ae9d1fa 100644 --- a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx @@ -1045,7 +1045,7 @@ void DAVResourceAccess::initialize() return; } - // Own URI is needed for redirect cycle detection. + // Own URI is needed to redirect cycle detection. m_aRedirectURIs.push_back( aURI ); // Success. @@ -1147,23 +1147,35 @@ bool DAVResourceAccess::handleException(DAVException const& e, int const errorCo return true; } return false; - // --> tkr #67048# copy & paste images doesn't display. - // if we have a bad connection try again. Up to three times. + // i#67048 copy & paste images doesn't display. This bug refers + // to an old OOo problem about getting resources from sites with a bad connection. + // If we have a bad connection try again. Up to three times. case DAVException::DAV_HTTP_ERROR: - // retry up to three times, if not a client-side error. - // exception: error 501, server side error that - // tells us the used method is not implemented - // on the server, it's nonsense to insist... - if ( ( e.getStatus() < 400 || e.getStatus() >= 500 || - e.getStatus() == 413 ) && - ( e.getStatus() != 501 ) && - errorCount < 3 ) - { + // retry up to three times, if not a client-side error (4xx error codes) + if ( e.getStatus() < SC_BAD_REQUEST && errorCount < 3 ) return true; + // check the server side errors + switch( e.getStatus() ) + { + // the HTTP server side response status codes that can be retried + // [Serf TODO? i#119036] case SC_REQUEST_ENTITY_TOO_LARGE: + case SC_BAD_GATEWAY: // retry, can be an excessive load + case SC_GATEWAY_TIMEOUT: // retry, may be we get lucky + case SC_SERVICE_UNAVAILABLE: // retry, the service may become available + case SC_INSUFFICIENT_STORAGE: // space may be freed, retry + { + if ( errorCount < 3 ) + return true; + else + return false; + } + break; + // all the other HTTP server response status codes are NOT retry + default: + return false; } - return false; - // <-- - // --> tkr: if connection has said retry then retry! + break; + // if connection has said retry then retry! case DAVException::DAV_HTTP_RETRY: return true; // <-- |