diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2024-03-08 11:20:45 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-03-27 14:33:17 +0100 |
commit | 49dfb3e6d12fd166a9884a5af7ec309d3eb9d1ac (patch) | |
tree | 4909db64129ee37ee3d9323f8682a826bd4d9caf /ucb | |
parent | 6872dc37b0fc4c73f00e8a8fe7a43737eb6d8fac (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)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164507
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.cxx | 19 |
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 4096115a40aa..1b38e0545351 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1835,7 +1835,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); @@ -2070,9 +2072,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); @@ -2100,9 +2101,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); @@ -2132,9 +2132,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); |