ucb/source/ucp/webdav-curl/CurlSession.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
New commits: commit e0259d4c0951c4dd77c74d08b9d905728d4c8dfd Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Mar 8 11:20:45 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Mar 8 16:26:06 2024 +0100 ucb: webdav-curl: only set CURLOPT_NOBODY for HEAD Some testing with Apache httpd+mod_dav reveals that it usually sends a body with a 401 status, which causes the CURLE_WEIRD_SERVER_REPLY error code from curl. So we should either ignore this error in case there's a HTTP status too, or stop using CURLOPT_NOBODY. The latter seems to have no downside, except for HEAD requests, where strangely the server keeps the connection open and curl waits for 5 seconds for no body to arrive, blocking the UI, so continue to use CURLOPT_NOBODY for HEAD. The other methods don't seem to block. It turns out that the SAL_LOG-dependent setting of g_NoBody turned HEAD into GET anyway if logging is enabled, so explicitly set the method. Change-Id: Ibe2eef8e7a827d4e356ba37c4b56bee0be3b9c13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164569 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 858af08b5efb..9cd1745326b6 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1936,7 +1936,9 @@ auto CurlSession::HEAD(OUString const& rURIReference, ::std::vector<OUString> co CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); - ::std::vector<CurlOption> const options{ g_NoBody }; + ::std::vector<CurlOption> const options{ + g_NoBody, { CURLOPT_CUSTOMREQUEST, "HEAD", "CURLOPT_CUSTOMREQUEST" } + }; ::std::pair<::std::vector<OUString> const&, DAVResource&> const headers(rHeaderNames, io_rResource); @@ -2171,9 +2173,8 @@ auto CurlSession::MKCOL(OUString const& rURIReference, DAVRequestEnvironment con CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); - ::std::vector<CurlOption> const options{ - g_NoBody, { CURLOPT_CUSTOMREQUEST, "MKCOL", "CURLOPT_CUSTOMREQUEST" } - }; + ::std::vector<CurlOption> const options{ { CURLOPT_CUSTOMREQUEST, "MKCOL", + "CURLOPT_CUSTOMREQUEST" } }; CurlProcessor::ProcessRequest(*this, uri, "MKCOL", options, &rEnv, nullptr, nullptr, nullptr, nullptr); @@ -2201,9 +2202,8 @@ auto CurlProcessor::MoveOrCopy(CurlSession& rSession, std::u16string_view rSourc throw uno::RuntimeException("curl_slist_append failed"); } - ::std::vector<CurlOption> const options{ - g_NoBody, { CURLOPT_CUSTOMREQUEST, pMethod, "CURLOPT_CUSTOMREQUEST" } - }; + ::std::vector<CurlOption> const options{ { CURLOPT_CUSTOMREQUEST, pMethod, + "CURLOPT_CUSTOMREQUEST" } }; CurlProcessor::ProcessRequest(rSession, uriSource, OUString::createFromAscii(pMethod), options, &rEnv, ::std::move(pList), nullptr, nullptr, nullptr); @@ -2233,9 +2233,8 @@ auto CurlSession::DESTROY(OUString const& rURIReference, DAVRequestEnvironment c CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); - ::std::vector<CurlOption> const options{ - g_NoBody, { CURLOPT_CUSTOMREQUEST, "DELETE", "CURLOPT_CUSTOMREQUEST" } - }; + ::std::vector<CurlOption> const options{ { CURLOPT_CUSTOMREQUEST, "DELETE", + "CURLOPT_CUSTOMREQUEST" } }; CurlProcessor::ProcessRequest(*this, uri, "DESTROY", options, &rEnv, nullptr, nullptr, nullptr, nullptr);