From 78d14ff6ef230ba3433d50ba8ded1a7cd2689b0f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 26 Nov 2021 14:46:16 +0100 Subject: ucb: webdav-curl: don't use chunked encoding for PROPPATCH Sharepoint 16 has the same problem with this as with PROPFIND. But this still doesn't work, trying to add dead properties results in HTTP/1.1 400 BAD REQUEST now. In fact, it has additional problems: request 3 properties Foo, Bar, Baz with one PROPFIND and it complains about Foo, FooBar, FooBarBaz... Change-Id: Ia0ce0f7b9422e0751839151a4c964f0437282c64 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125907 Tested-by: Jenkins Reviewed-by: Michael Stahl --- ucb/source/ucp/webdav-curl/CurlSession.cxx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'ucb/source') diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 5ea645f4d4ee..43bfa6cb85f8 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1588,25 +1588,17 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference, CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked? - ::std::unique_ptr> pList( - curl_slist_append(nullptr, "Transfer-Encoding: chunked")); - if (!pList) - { - throw uno::RuntimeException("curl_slist_append failed"); - } + ::std::unique_ptr> pList; pList.reset(curl_slist_append(pList.release(), "Content-Type: application/xml")); if (!pList) { throw uno::RuntimeException("curl_slist_append failed"); } - ::std::vector const options{ { CURLOPT_CUSTOMREQUEST, "PROPPATCH", - "CURLOPT_CUSTOMREQUEST" } }; - // generate XML document for PROPPATCH - uno::Reference const xRequestInStream(io::Pipe::create(m_xContext)); - uno::Reference const xRequestOutStream(xRequestInStream, uno::UNO_QUERY); - assert(xRequestInStream.is()); + uno::Reference const xSeqOutStream( + io::SequenceOutputStream::create(m_xContext)); + uno::Reference const xRequestOutStream(xSeqOutStream); assert(xRequestOutStream.is()); uno::Reference const xWriter(xml::sax::Writer::create(m_xContext)); xWriter->setOutputStream(xRequestOutStream); @@ -1657,7 +1649,19 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference, } xWriter->endElement("propertyupdate"); xWriter->endDocument(); - xRequestOutStream->closeOutput(); + + uno::Reference const xRequestInStream( + io::SequenceInputStream::createStreamFromSequence(m_xContext, + xSeqOutStream->getWrittenBytes())); + assert(xRequestInStream.is()); + + curl_off_t const len(xSeqOutStream->getWrittenBytes().getLength()); + + ::std::vector const options{ + { CURLOPT_CUSTOMREQUEST, "PROPPATCH", "CURLOPT_CUSTOMREQUEST" }, + // note: Sharepoint cannot handle "Transfer-Encoding: chunked" + { CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT } + }; CurlProcessor::ProcessRequest(*this, uri, options, &rEnv, ::std::move(pList), nullptr, &xRequestInStream, nullptr); -- cgit