diff options
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.cxx | 24 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVException.hxx | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 0f06363ce68f..bb1d4689a53c 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -964,6 +964,8 @@ auto CurlProcessor::ProcessRequestImpl( "curl_easy_perform failed: " << GetErrorString(rc, rSession.m_ErrorBuffer)); switch (rc) { + case CURLE_UNSUPPORTED_PROTOCOL: + throw DAVException(DAVException::DAV_UNSUPPORTED); case CURLE_COULDNT_RESOLVE_PROXY: throw DAVException( DAVException::DAV_HTTP_LOOKUP, @@ -1250,6 +1252,7 @@ auto CurlProcessor::ProcessRequest( } } bool isRetry(false); + bool isFallbackHTTP10(false); int nAuthRequests(0); int nAuthRequestsProxy(0); @@ -1473,6 +1476,27 @@ auto CurlProcessor::ProcessRequest( } } } + else if (rException.getError() == DAVException::DAV_UNSUPPORTED) + { + // tdf#152493 libcurl can't handle "Transfer-Encoding: chunked" + // in HTTP/1.1 100 Continue response. + // workaround: if HTTP/1.1 didn't work, try HTTP/1.0 + // (but fallback only once - to prevent infinite loop) + if (isFallbackHTTP10) + { + throw DAVException(DAVException::DAV_HTTP_ERROR); + } + isFallbackHTTP10 = true; + // note: this is not reset - future requests to this URI use it! + auto rc = curl_easy_setopt(rSession.m_pCurl.get(), CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_0); + if (rc != CURLE_OK) + { + throw DAVException(DAVException::DAV_HTTP_ERROR); + } + SAL_INFO("ucb.ucp.webdav.curl", "attempting fallback to HTTP/1.0"); + isRetry = true; + } if (!isRetry) { throw; // everything else: re-throw diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx b/ucb/source/ucp/webdav-curl/DAVException.hxx index 84dba895485c..759e43f25f8e 100644 --- a/ucb/source/ucp/webdav-curl/DAVException.hxx +++ b/ucb/source/ucp/webdav-curl/DAVException.hxx @@ -130,6 +130,7 @@ class DAVException : public std::exception DAV_SESSION_CREATE, // session creation error, // mData = server[:port] DAV_INVALID_ARG, // invalid argument + DAV_UNSUPPORTED, // internal to CurlSession DAV_LOCK_EXPIRED, // DAV lock expired |