summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-01-17 19:07:52 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-01-18 15:08:32 +0100
commit71963c56241cecc77a2bff5434f0a1cf759d744f (patch)
tree1fa4b89be3ecdf7e65dbfc609a620c97eba7f867 /ucb
parentc517c71a52ba9f35df42b501c5b17362528f8b03 (diff)
ucb: webdav-curl: add even more logging
Some servers like to put error messages in the body if there's a problem, let's try to to dump that via SAL_INFO, unless it's too big. Change-Id: I9a29de59ab299f4bfda08ecc3be838972cf0c71d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128513 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit d32e7ddb6497c3b36b86589765790dbfc3de335e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128533 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx39
1 files changed, 38 insertions, 1 deletions
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index c30b0c775131..ee21e88fc44d 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1273,14 +1273,51 @@ auto CurlProcessor::ProcessRequest(
}
ResponseHeaders headers(rSession.m_pCurl.get());
+ uno::Reference<io::XSequenceOutputStream> xSeqOutStream;
+ uno::Reference<io::XOutputStream> xDebugOutStream;
+ if (!pxOutStream)
+ {
+ xSeqOutStream = io::SequenceOutputStream::create(rSession.m_xContext);
+ xDebugOutStream = xSeqOutStream;
+ }
try
{
- ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(), pxOutStream,
+ ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(),
+ pxOutStream ? pxOutStream : &xDebugOutStream,
pxInStream ? &data : nullptr, pRequestedHeaders, headers);
}
catch (DAVException const& rException)
{
+ if (xDebugOutStream.is())
+ {
+ auto const bytes(xSeqOutStream->getWrittenBytes());
+ auto const len(::std::min<sal_Int32>(bytes.getLength(), 10000));
+ SAL_INFO("ucb.ucp.webdav.curl",
+ "DAVException; (first) " << len << " bytes of data received:");
+ if (0 < len)
+ {
+ OStringBuffer buf(len);
+ for (sal_Int32 i = 0; i < len; ++i)
+ {
+ if (bytes[i] < 0x20) // also if negative
+ {
+ static char const hexDigit[16]
+ = { '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+ buf.append("\\x");
+ buf.append(hexDigit[static_cast<sal_uInt8>(bytes[i]) >> 4]);
+ buf.append(hexDigit[bytes[i] & 0x0F]);
+ }
+ else
+ {
+ buf.append(static_cast<char>(bytes[i]));
+ }
+ }
+ SAL_INFO("ucb.ucp.webdav.curl", buf.makeStringAndClear());
+ }
+ }
+
// error handling part 3: special HTTP status codes
// that require unlocking m_Mutex to handle
if (rException.getError() == DAVException::DAV_HTTP_ERROR)