2016-06-12 22:27:24 +02:00
|
|
|
#ifndef QTHTTPREQUEST_H
|
|
|
|
#define QTHTTPREQUEST_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QUrl>
|
2016-06-19 00:56:47 +02:00
|
|
|
#include <QHostAddress>
|
2017-01-14 19:04:58 +01:00
|
|
|
#include <QMap>
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
class QtHttpServer;
|
2017-01-14 19:04:58 +01:00
|
|
|
class QtHttpClientWrapper;
|
|
|
|
|
|
|
|
using QtHttpPostData = QMap<QString,QByteArray>;
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
class QtHttpRequest : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-01-14 19:04:58 +01:00
|
|
|
explicit QtHttpRequest (QtHttpClientWrapper * client, QtHttpServer * parent);
|
2016-06-12 22:27:24 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
struct ClientInfo {
|
2017-01-14 19:04:58 +01:00
|
|
|
QHostAddress serverAddress;
|
|
|
|
QHostAddress clientAddress;
|
2016-06-19 00:56:47 +02:00
|
|
|
};
|
|
|
|
|
2017-01-14 19:04:58 +01:00
|
|
|
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;
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
QByteArray getHeader (const QByteArray & header) const;
|
2017-01-14 19:04:58 +01:00
|
|
|
QtHttpPostData getPostData (void) const;
|
|
|
|
|
|
|
|
ClientInfo getClientInfo (void) const;
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setUrl (const QUrl & url);
|
|
|
|
void setCommand (const QString & command);
|
2016-06-19 00:56:47 +02:00
|
|
|
void setClientInfo (const QHostAddress & server, const QHostAddress & client);
|
2016-06-12 22:27:24 +02:00
|
|
|
void addHeader (const QByteArray & header, const QByteArray & value);
|
|
|
|
void appendRawData (const QByteArray & data);
|
2017-01-14 19:04:58 +01:00
|
|
|
void setPostData (const QtHttpPostData & data);
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
QUrl m_url;
|
|
|
|
QString m_command;
|
|
|
|
QByteArray m_data;
|
|
|
|
QtHttpServer * m_serverHandle;
|
2017-01-14 19:04:58 +01:00
|
|
|
QtHttpClientWrapper * m_clientHandle;
|
2016-06-12 22:27:24 +02:00
|
|
|
QHash<QByteArray, QByteArray> m_headersHash;
|
2016-06-19 00:56:47 +02:00
|
|
|
ClientInfo m_clientInfo;
|
2017-01-14 19:04:58 +01:00
|
|
|
QtHttpPostData m_postData;
|
2016-06-12 22:27:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QTHTTPREQUEST_H
|