2017-07-12 20:12:17 +02:00
|
|
|
#ifndef REQUESTLOGGING_HPP
|
|
|
|
#define REQUESTLOGGING_HPP
|
|
|
|
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QNetworkReply>
|
2017-08-20 17:06:44 +02:00
|
|
|
#include <settings.hpp>
|
2017-07-12 20:12:17 +02:00
|
|
|
|
2017-08-21 16:17:20 +02:00
|
|
|
|
|
|
|
namespace requestlogging {
|
2017-07-12 20:12:17 +02:00
|
|
|
struct RequestContext {
|
|
|
|
QByteArray response;
|
|
|
|
QNetworkReply *reply;
|
|
|
|
};
|
|
|
|
|
2017-08-20 17:06:44 +02:00
|
|
|
class LoggedRequest {
|
|
|
|
friend QList<LoggedRequest> getRequests();
|
|
|
|
|
|
|
|
public:
|
|
|
|
QString getUrl() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
QString getType() {
|
|
|
|
return type;
|
|
|
|
}
|
2017-08-21 16:17:20 +02:00
|
|
|
QString getTime() {
|
2017-08-20 17:06:44 +02:00
|
|
|
return time;
|
|
|
|
}
|
|
|
|
int getResponseCode() {
|
|
|
|
return responseCode;
|
|
|
|
}
|
|
|
|
QByteArray getResponse() {
|
2017-08-21 16:17:20 +02:00
|
|
|
return QFile(settings::dir().absoluteFilePath("responses/" + time)).readAll();
|
2017-08-20 17:06:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString url;
|
|
|
|
QString type;
|
2017-08-21 16:17:20 +02:00
|
|
|
QString time;
|
2017-08-20 17:06:44 +02:00
|
|
|
int responseCode;
|
|
|
|
};
|
|
|
|
|
|
|
|
QList<LoggedRequest> getRequests();
|
2017-08-21 16:17:20 +02:00
|
|
|
void addEntry(RequestContext context);
|
2017-07-12 20:12:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // REQUESTLOGGING_HPP
|