aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/connection.cpp13
-rw-r--r--lib/jobs/basejob.cpp5
-rw-r--r--lib/jobs/basejob.h2
3 files changed, 13 insertions, 7 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index d363b433..1f6cc67a 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -65,6 +65,10 @@ HashT erase_if(HashT& hashMap, Pred pred)
return removals;
}
+#ifndef TRIM_RAW_DATA
+#define TRIM_RAW_DATA 65535
+#endif
+
class Connection::Private
{
public:
@@ -198,7 +202,8 @@ void Connection::doConnectToServer(const QString& user, const QString& password,
});
connect(loginJob, &BaseJob::failure, this,
[this, loginJob] {
- emit loginError(loginJob->errorString(), loginJob->rawData());
+ emit loginError(loginJob->errorString(),
+ loginJob->rawData(TRIM_RAW_DATA));
});
}
@@ -274,7 +279,7 @@ void Connection::sync(int timeout)
connect( job, &SyncJob::retryScheduled, this,
[this,job] (int retriesTaken, int nextInMilliseconds)
{
- emit networkError(job->errorString(), job->rawData(),
+ emit networkError(job->errorString(), job->rawData(TRIM_RAW_DATA),
retriesTaken, nextInMilliseconds);
});
connect( job, &SyncJob::failure, this, [this, job] {
@@ -283,10 +288,10 @@ void Connection::sync(int timeout)
{
qCWarning(SYNCJOB)
<< "Sync job failed with ContentAccessError - login expired?";
- emit loginError(job->errorString(), job->rawData());
+ emit loginError(job->errorString(), job->rawData(TRIM_RAW_DATA));
}
else
- emit syncError(job->errorString(), job->rawData());
+ emit syncError(job->errorString(), job->rawData(TRIM_RAW_DATA));
});
}
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index 2a6705b8..607a6c04 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -509,9 +509,10 @@ BaseJob::Status BaseJob::status() const
return d->status;
}
-QByteArray BaseJob::rawData() const
+QByteArray BaseJob::rawData(int bytesAtMost) const
{
- return d->rawResponse;
+ return bytesAtMost > 0 ?
+ d->rawResponse.left(bytesAtMost) + "...(truncated)" : d->rawResponse;
}
QString BaseJob::statusCaption() const
diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h
index c34ba3c3..4ef25ab8 100644
--- a/lib/jobs/basejob.h
+++ b/lib/jobs/basejob.h
@@ -139,7 +139,7 @@ namespace QMatrixClient
/** Short human-friendly message on the job status */
QString statusCaption() const;
/** Raw response body as received from the server */
- QByteArray rawData() const;
+ QByteArray rawData(int bytesAtMost = -1) const;
/** Error (more generally, status) code
* Equivalent to status().code