summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-03-08 11:20:45 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2024-03-12 14:51:32 +0100
commitb0aeac2376ee5d74373e35eace8258a500e7cf00 (patch)
tree54a8f8633c6fe20eea4589536e29c0c7ae79ecb5
parent4c6574abe8cca7d74129c12c486b722c668fdaba (diff)
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.stahl@allotropia.de> (cherry picked from commit e0259d4c0951c4dd77c74d08b9d905728d4c8dfd)
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 645d41502156..4bae872b1757 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1914,7 +1914,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);
@@ -2147,9 +2149,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);
@@ -2177,9 +2178,8 @@ auto CurlProcessor::MoveOrCopy(CurlSession& rSession, OUString const& rSourceURI
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);
@@ -2209,9 +2209,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);