summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-11-25 18:24:06 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-26 12:24:33 +0100
commitf50d0ca0978d8c6b8dff5ce680bce9fe71c0a7dd (patch)
treeca26d4e6504f651a1640a493c9dc2f79944f3d53 /ucb
parent403d3e057575825f86ff97bf9e277feafa69362e (diff)
ucb: webdav-curl: don't use chunked encoding for LOCK
Sharepoint 16 produces exactly the same error HTML as for PROPFIND. Change-Id: Idd3862456c4efbb9eb0533298dcd93711b30faae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125847 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx35
1 files changed, 22 insertions, 13 deletions
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index ca5fedd3b280..fc478efec7fd 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1980,8 +1980,19 @@ auto CurlProcessor::Lock(
uno::Reference<io::XInputStream> const* const pxRequestInStream)
-> ::std::vector<::std::pair<ucb::Lock, sal_Int32>>
{
- ::std::vector<CurlOption> const options{ { CURLOPT_CUSTOMREQUEST, "LOCK",
- "CURLOPT_CUSTOMREQUEST" } };
+ curl_off_t len(0);
+ if (pxRequestInStream)
+ {
+ uno::Reference<io::XSeekable> const xSeekable(*pxRequestInStream, uno::UNO_QUERY);
+ assert(xSeekable.is());
+ len = xSeekable->getLength();
+ }
+
+ ::std::vector<CurlOption> const options{
+ { CURLOPT_CUSTOMREQUEST, "LOCK", "CURLOPT_CUSTOMREQUEST" },
+ // note: Sharepoint cannot handle "Transfer-Encoding: chunked"
+ { CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
+ };
// stream for response
uno::Reference<io::XInputStream> const xResponseInStream(io::Pipe::create(rSession.m_xContext));
@@ -2047,9 +2058,9 @@ auto CurlSession::LOCK(OUString const& rURIReference, ucb::Lock /*const*/& rLock
// note: no m_Mutex lock needed here, only in CurlProcessor::Lock()
// generate XML document for acquiring new LOCK
- uno::Reference<io::XInputStream> const xRequestInStream(io::Pipe::create(m_xContext));
- uno::Reference<io::XOutputStream> const xRequestOutStream(xRequestInStream, uno::UNO_QUERY);
- assert(xRequestInStream.is());
+ uno::Reference<io::XSequenceOutputStream> const xSeqOutStream(
+ io::SequenceOutputStream::create(m_xContext));
+ uno::Reference<io::XOutputStream> const xRequestOutStream(xSeqOutStream);
assert(xRequestOutStream.is());
uno::Reference<xml::sax::XWriter> const xWriter(xml::sax::Writer::create(m_xContext));
xWriter->setOutputStream(xRequestOutStream);
@@ -2085,15 +2096,13 @@ auto CurlSession::LOCK(OUString const& rURIReference, ucb::Lock /*const*/& rLock
}
xWriter->endElement("lockinfo");
xWriter->endDocument();
- xRequestOutStream->closeOutput();
- // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked?
- ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> pList(
- curl_slist_append(nullptr, "Transfer-Encoding: chunked"));
- if (!pList)
- {
- throw uno::RuntimeException("curl_slist_append failed");
- }
+ uno::Reference<io::XInputStream> const xRequestInStream(
+ io::SequenceInputStream::createStreamFromSequence(m_xContext,
+ xSeqOutStream->getWrittenBytes()));
+ assert(xRequestInStream.is());
+
+ ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> pList;
pList.reset(curl_slist_append(pList.release(), "Content-Type: application/xml"));
if (!pList)
{