mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-11 12:22:14 +08:00
775ed1428f
old-commit-hash: 85f134da6a1e96e1d4b2e70669cab120f000c2bd
42 lines
926 B
C++
42 lines
926 B
C++
#pragma once
|
|
|
|
#include <QJsonObject>
|
|
#include <QNetworkReply>
|
|
#include <QString>
|
|
#include <QTimer>
|
|
|
|
namespace CommaApi {
|
|
|
|
QByteArray rsa_sign(const QByteArray &data);
|
|
QString create_jwt(const QJsonObject &payloads = {}, int expiry = 3600);
|
|
|
|
} // namespace CommaApi
|
|
|
|
/**
|
|
* Makes a request to the request endpoint.
|
|
*/
|
|
|
|
class HttpRequest : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit HttpRequest(QObject* parent, const QString &requestURL, const QString &cache_key = "", bool create_jwt_ = true);
|
|
QNetworkReply *reply;
|
|
void sendRequest(const QString &requestURL);
|
|
|
|
private:
|
|
QNetworkAccessManager *networkAccessManager;
|
|
QTimer *networkTimer;
|
|
QString cache_key;
|
|
bool create_jwt;
|
|
|
|
private slots:
|
|
void requestTimeout();
|
|
void requestFinished();
|
|
|
|
signals:
|
|
void receivedResponse(const QString &response);
|
|
void failedResponse(const QString &errorString);
|
|
void timeoutResponse(const QString &errorString);
|
|
};
|