1#include "testengine.hpp"
3#include "testengine_p.h"
9TestEngine::TestEngine(
Application *app,
const QVariantMap &opts)
14int TestEngine::workerId()
const
19TestEngine::TestResponse TestEngine::createRequest(
const QByteArray &method,
29 bodyDevice =
new SequentialBuffer(body);
34 if (bodyDevice->
size()) {
38 TestEngineConnection req;
43 req.protocol =
"HTTP/1.1"_qba;
45 req.serverAddress =
"127.0.0.1"_qba;
47 req.remotePort = 3000;
49 req.headers = headersCL;
50 req.startOfRequest = std::chrono::steady_clock::now();
51 req.body = bodyDevice;
53 Q_EMIT processRequestAsync(&req);
56 req.m_eventLoop.exec();
59 ret.body = req.m_responseData;
60 ret.statusCode = req.m_statusCode;
61 ret.headers = req.m_headers;
66TestEngine::TestResponse TestEngine::createRequest(
const QByteArray &method,
72 return createRequest(method, path.
toLatin1(), query, headers, body);
75bool TestEngine::init()
77 return initApplication() && postForkApplication();
80QByteArray TestEngine::httpStatus(quint16 status)
83 const auto *statusChar = httpStatusMessage(status, &len);
87SequentialBuffer::SequentialBuffer(
QByteArray *buffer)
92bool SequentialBuffer::isSequential()
const
97qint64 SequentialBuffer::bytesAvailable()
const
102qint64 SequentialBuffer::readData(
char *data, qint64 maxlen)
105 memcpy(data, mid.
data(), mid.
size());
107 buf->remove(0, mid.
size());
111qint64 SequentialBuffer::writeData(
const char *data, qint64 len)
118qint64 TestEngineConnection::doWrite(
const char *data, qint64 len)
120 m_responseData.append(data, len);
124bool TestEngineConnection::writeHeaders(quint16 status,
const Headers &headers)
126 m_statusCode = status;
132void TestEngineConnection::processingFinished()
137#include "moc_testengine.cpp"
The Cutelyst application.
The Cutelyst namespace holds all public Cutelyst API.
bool isEmpty() const const
QByteArray mid(qsizetype pos, qsizetype len) const const
qsizetype size() const const
virtual qint64 bytesAvailable() const const
virtual bool open(QIODeviceBase::OpenMode mode)
virtual qint64 size() const const
QByteArray toLatin1() const const