diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-26 14:46:16 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-26 18:04:12 +0100 |
commit | 78d14ff6ef230ba3433d50ba8ded1a7cd2689b0f (patch) | |
tree | 90638b22db5b19618b37c3f51791e2d27b770000 /ucb/source | |
parent | bf74eb1d1623a51805f91a973bc9f726d14dd7a8 (diff) |
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 <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb/source')
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.cxx | 30 |
1 files changed, 17 insertions, 13 deletions
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<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"); - } + ::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) { throw uno::RuntimeException("curl_slist_append failed"); } - ::std::vector<CurlOption> const options{ { CURLOPT_CUSTOMREQUEST, "PROPPATCH", - "CURLOPT_CUSTOMREQUEST" } }; - // generate XML document for PROPPATCH - 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); @@ -1657,7 +1649,19 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference, } xWriter->endElement("propertyupdate"); xWriter->endDocument(); - xRequestOutStream->closeOutput(); + + uno::Reference<io::XInputStream> const xRequestInStream( + io::SequenceInputStream::createStreamFromSequence(m_xContext, + xSeqOutStream->getWrittenBytes())); + assert(xRequestInStream.is()); + + curl_off_t const len(xSeqOutStream->getWrittenBytes().getLength()); + + ::std::vector<CurlOption> 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); |