cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
enginerequest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: (C) 2017-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
12#ifndef ENGINEREQUEST_H
13#define ENGINEREQUEST_H
14
15#include <Cutelyst/Headers>
16
17#include <QElapsedTimer>
18#include <QHostAddress>
19#include <QObject>
20
21namespace Cutelyst {
22
23class Engine;
24class Context;
25class CUTELYST_LIBRARY EngineRequest
26{
27 Q_GADGET
28 friend class Engine;
29
30public:
31 enum StatusFlag {
32 InitialState = 0x00,
33 FinalizedHeaders = 0x01,
34 IOWrite = 0x02,
35 Chunked = 0x04,
36 ChunkedDone = 0x08,
37 Async = 0x10,
38 Finalized = 0x20,
39 };
40 Q_DECLARE_FLAGS(Status, StatusFlag)
41
42 explicit EngineRequest();
43
44 virtual ~EngineRequest();
45
50 virtual void finalizeBody();
51
58 virtual void finalizeError();
59
64 void finalize();
65
71 virtual void finalizeCookies();
72
78 virtual bool finalizeHeaders();
79
83 qint64 write(const char *data, qint64 len);
84
85 bool webSocketHandshake(const QString &key, const QString &origin, const QString &protocol);
86
87 virtual bool webSocketSendTextMessage(const QString &message);
88
89 virtual bool webSocketSendBinaryMessage(const QByteArray &message);
90
91 virtual bool webSocketSendPing(const QByteArray &payload);
92
93 virtual bool webSocketClose(quint16 code, const QString &reason);
94
95protected:
99 virtual qint64 doWrite(const char *data, qint64 len) = 0;
100
111 virtual void processingFinished();
112
116 virtual bool writeHeaders(quint16 status, const Headers &headers) = 0;
117
118 virtual bool
119 webSocketHandshakeDo(const QString &key, const QString &origin, const QString &protocol);
120
121public:
128 void setPath(char *rawPath, const int len);
129
130 inline void setPath(const QString &path)
131 {
132 QByteArray rawPath = path.toLatin1();
133 setPath(rawPath.data(), rawPath.size());
134 }
135
138
141
144
147
152
155
158
161
163 quint64 startOfRequest = 0;
164
166 Status status = InitialState;
167
170 QIODevice *body = nullptr;
171
174 Context *context = nullptr;
175
177 quint16 remotePort = 0;
178
180 bool isSecure = false;
181
184};
185
186} // namespace Cutelyst
187
188Q_DECLARE_OPERATORS_FOR_FLAGS(Cutelyst::EngineRequest::Status)
189
190#endif // ENGINEREQUEST_H
The Cutelyst Context.
Definition context.h:39
virtual qint64 doWrite(const char *data, qint64 len)=0
Reimplement this to do the RAW writing to the client.
QString method
The method used (GET, POST...)
QString path
Call setPath() instead.
QByteArray query
The query string requested by the user agent 'foo=bar&baz'.
QHostAddress remoteAddress
The remote/client address.
QString remoteUser
The remote user name set by a front web server.
Headers headers
The request headers.
virtual bool writeHeaders(quint16 status, const Headers &headers)=0
Reimplement this to write the headers back to the client.
QString serverAddress
The server address which the server is listening to, usually the 'Host' header but if that's not pres...
QElapsedTimer elapsed
The elapsed timer since the start of request.
QString protocol
The protocol requested by the user agent 'HTTP1/1'.
The Cutelyst Engine.
Definition engine.h:21
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8
char * data()
int size() const const
QByteArray toLatin1() const const