ucb/source/ucp/webdav-curl/CurlSession.cxx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
New commits: commit 012aa0a6e454fd15f91ac89d98faa30339e145c1 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Mar 8 11:20:45 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Mar 31 22:38:38 2024 +0200 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> (cherry picked from commit e0259d4c0951c4dd77c74d08b9d905728d4c8dfd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164508 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 34fb5438150e..1ca713337d60 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1852,7 +1852,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); @@ -2087,9 +2089,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); @@ -2117,9 +2118,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); @@ -2149,9 +2149,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); commit fd9ad62bb93a44e3deadaef7f84f916c7ab19a51 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 7 20:10:48 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Mar 31 22:38:29 2024 +0200 ucb: webdav-curl: don't set CURLOPT_NOBODY for OPTIONS The problem is that if the server does send a body, then curl returns CURLE_WEIRD_SERVER_REPLY error code, which is translated to DAVException; this looks unnecessary now because write_callback will just return if there's no stream to write to anyway. Change-Id: Iddaee9778ac7bbd538b64584f822f65ab0e395c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164550 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 980ca3953084560806cd980d2ec16951d9e30c2b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164502 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index f046395a668e..34fb5438150e 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1543,9 +1543,8 @@ auto CurlSession::OPTIONS(OUString const& rURIReference, DAVResource result; ::std::pair<::std::vector<OUString> const&, DAVResource&> const headers(headerNames, result); - ::std::vector<CurlOption> const options{ - g_NoBody, { CURLOPT_CUSTOMREQUEST, "OPTIONS", "CURLOPT_CUSTOMREQUEST" } - }; + ::std::vector<CurlOption> const options{ { CURLOPT_CUSTOMREQUEST, "OPTIONS", + "CURLOPT_CUSTOMREQUEST" } }; CurlProcessor::ProcessRequest(*this, uri, "OPTIONS", options, &rEnv, nullptr, nullptr, nullptr, &headers);