diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-17 19:07:52 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-18 10:52:07 +0100 |
commit | d32e7ddb6497c3b36b86589765790dbfc3de335e (patch) | |
tree | 8f624766f49c56f07051e93175260821de015ef1 | |
parent | 3122b12cbf7c0da2b717cbbd0b7848e02f1c7a6f (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>
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.cxx | 39 |
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 89c60cbac1cc..9af6c4284355 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1271,14 +1271,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) |