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
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
class QtHttpRequest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
public:
|
2019-07-21 15:03:50 +02:00
|
|
|
explicit QtHttpRequest (QtHttpClientWrapper * client, QtHttpServer * parent);
|
2016-06-12 22:27:24 +02:00
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
struct ClientInfo
|
|
|
|
{
|
|
|
|
QHostAddress serverAddress;
|
|
|
|
QHostAddress clientAddress;
|
|
|
|
};
|
2016-06-19 00:56:47 +02:00
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
int getRawDataSize (void) const { return m_data.size (); };
|
|
|
|
QUrl getUrl (void) const { return m_url; };
|
|
|
|
QString getCommand (void) const { return m_command; };
|
|
|
|
QByteArray getRawData (void) const { return m_data; };
|
|
|
|
QList<QByteArray> getHeadersList (void) const { return m_headersHash.keys (); };
|
|
|
|
QtHttpClientWrapper * getClient (void) const { return m_clientHandle; };
|
|
|
|
QtHttpPostData getPostData (void) const { return m_postData; };
|
|
|
|
ClientInfo getClientInfo (void) const { return m_clientInfo; };
|
2016-06-12 22:27:24 +02:00
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
QByteArray getHeader (const QByteArray & header) const
|
|
|
|
{
|
2022-02-22 20:58:59 +01:00
|
|
|
return m_headersHash.value (header.toLower(), QByteArray ());
|
2019-07-21 15:03:50 +02:00
|
|
|
};
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
public slots:
|
2019-07-21 15:03:50 +02:00
|
|
|
void setUrl (const QUrl & url) { m_url = url; };
|
|
|
|
void setCommand (const QString & command) { m_command = command; };
|
|
|
|
void appendRawData (const QByteArray & data) { m_data.append (data); };
|
|
|
|
void setPostData (const QtHttpPostData & data) { m_postData = data; };
|
|
|
|
|
|
|
|
void setClientInfo (const QHostAddress & server, const QHostAddress & client);
|
|
|
|
void addHeader (const QByteArray & header, const QByteArray & value);
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
private:
|
2019-07-21 15:03:50 +02:00
|
|
|
QUrl m_url;
|
|
|
|
QString m_command;
|
|
|
|
QByteArray m_data;
|
|
|
|
QtHttpServer * m_serverHandle;
|
|
|
|
QtHttpClientWrapper * m_clientHandle;
|
|
|
|
QHash<QByteArray, QByteArray> m_headersHash;
|
|
|
|
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
|