hyperion.ng/libsrc/webconfig/QtHttpRequest.h
redPanther 8a9d2760ef move write config from json api to http post (#363)
* implement config save over http post instead of json

* remove json set config
finish config write thrugh http post

* remove debug code and add failure messages
2017-01-14 19:04:58 +01:00

60 lines
1.8 KiB
C++

#ifndef QTHTTPREQUEST_H
#define QTHTTPREQUEST_H
#include <QObject>
#include <QString>
#include <QByteArray>
#include <QHash>
#include <QUrl>
#include <QHostAddress>
#include <QMap>
class QtHttpServer;
class QtHttpClientWrapper;
using QtHttpPostData = QMap<QString,QByteArray>;
class QtHttpRequest : public QObject {
Q_OBJECT
public:
explicit QtHttpRequest (QtHttpClientWrapper * client, QtHttpServer * parent);
struct ClientInfo {
QHostAddress serverAddress;
QHostAddress clientAddress;
};
int getRawDataSize (void) const;
QUrl getUrl (void) const;
QString getCommand (void) const;
QByteArray getRawData (void) const;
QList<QByteArray> getHeadersList (void) const;
QtHttpClientWrapper * getClient (void) const;
QByteArray getHeader (const QByteArray & header) const;
QtHttpPostData getPostData (void) const;
ClientInfo getClientInfo (void) const;
public slots:
void setUrl (const QUrl & url);
void setCommand (const QString & command);
void setClientInfo (const QHostAddress & server, const QHostAddress & client);
void addHeader (const QByteArray & header, const QByteArray & value);
void appendRawData (const QByteArray & data);
void setPostData (const QtHttpPostData & data);
private:
QUrl m_url;
QString m_command;
QByteArray m_data;
QtHttpServer * m_serverHandle;
QtHttpClientWrapper * m_clientHandle;
QHash<QByteArray, QByteArray> m_headersHash;
ClientInfo m_clientInfo;
QtHttpPostData m_postData;
};
#endif // QTHTTPREQUEST_H