2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
#include "QtHttpRequest.h"
|
|
|
|
#include "QtHttpHeader.h"
|
|
|
|
#include "QtHttpServer.h"
|
|
|
|
|
2017-01-14 19:04:58 +01:00
|
|
|
QtHttpRequest::QtHttpRequest (QtHttpClientWrapper * client, QtHttpServer * parent)
|
2019-07-21 15:03:50 +02:00
|
|
|
: QObject (parent)
|
|
|
|
, m_url (QUrl ())
|
|
|
|
, m_command (QString ())
|
|
|
|
, m_data (QByteArray ())
|
|
|
|
, m_serverHandle (parent)
|
|
|
|
, m_clientHandle (client)
|
|
|
|
, m_postData (QtHttpPostData())
|
2016-06-12 22:27:24 +02:00
|
|
|
{
|
2019-07-21 15:03:50 +02:00
|
|
|
// set some additional headers
|
|
|
|
addHeader (QtHttpHeader::ContentLength, QByteArrayLiteral ("0"));
|
|
|
|
addHeader (QtHttpHeader::Connection, QByteArrayLiteral ("Keep-Alive"));
|
2016-06-12 22:27:24 +02:00
|
|
|
}
|
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
void QtHttpRequest::setClientInfo (const QHostAddress & server, const QHostAddress & client)
|
|
|
|
{
|
|
|
|
m_clientInfo.serverAddress = server;
|
|
|
|
m_clientInfo.clientAddress = client;
|
2016-06-12 22:27:24 +02:00
|
|
|
}
|
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
void QtHttpRequest::addHeader (const QByteArray & header, const QByteArray & value)
|
|
|
|
{
|
|
|
|
QByteArray key = header.trimmed ();
|
2017-01-14 19:04:58 +01:00
|
|
|
|
2019-07-21 15:03:50 +02:00
|
|
|
if (!key.isEmpty ())
|
|
|
|
{
|
|
|
|
m_headersHash.insert (key, value);
|
|
|
|
}
|
2017-01-14 19:04:58 +01:00
|
|
|
}
|