5#include "application.h"
10#include "response_p.h"
14#include <QJsonDocument>
43 : d_ptr(new EnginePrivate)
78 qCCritical(CUTELYST_ENGINE) <<
"Cannot init application on a different thread";
82 if (!d->app->setup(
this)) {
83 qCCritical(CUTELYST_ENGINE) <<
"Failed to setup application";
95 qCCritical(CUTELYST_ENGINE) <<
"Failed to postForkApplication on a null application";
101 return d->app->enginePostFork();
109 ret =
"HTTP/1.1 200 OK";
111 case Response::Found:
112 ret =
"HTTP/1.1 302 Found";
114 case Response::NotFound:
115 ret =
"HTTP/1.1 404 Not Found";
117 case Response::InternalServerError:
118 ret =
"HTTP/1.1 500 Internal Server Error";
120 case Response::MovedPermanently:
121 ret =
"HTTP/1.1 301 Moved Permanently";
123 case Response::NotModified:
124 ret =
"HTTP/1.1 304 Not Modified";
126 case Response::SeeOther:
127 ret =
"HTTP/1.1 303 See Other";
129 case Response::Forbidden:
130 ret =
"HTTP/1.1 403 Forbidden";
132 case Response::TemporaryRedirect:
133 ret =
"HTTP/1.1 307 Temporary Redirect";
135 case Response::Unauthorized:
136 ret =
"HTTP/1.1 401 Unauthorized";
138 case Response::BadRequest:
139 ret =
"HTTP/1.1 400 Bad Request";
141 case Response::MethodNotAllowed:
142 ret =
"HTTP/1.1 405 Method Not Allowed";
144 case Response::RequestTimeout:
145 ret =
"HTTP/1.1 408 Request Timeout";
147 case Response::Continue:
148 ret =
"HTTP/1.1 100 Continue";
150 case Response::SwitchingProtocols:
151 ret =
"HTTP/1.1 101 Switching Protocols";
153 case Response::Created:
154 ret =
"HTTP/1.1 201 Created";
156 case Response::Accepted:
157 ret =
"HTTP/1.1 202 Accepted";
159 case Response::NonAuthoritativeInformation:
160 ret =
"HTTP/1.1 203 Non-Authoritative Information";
162 case Response::NoContent:
163 ret =
"HTTP/1.1 204 No Content";
165 case Response::ResetContent:
166 ret =
"HTTP/1.1 205 Reset Content";
168 case Response::PartialContent:
169 ret =
"HTTP/1.1 206 Partial Content";
171 case Response::MultipleChoices:
172 ret =
"HTTP/1.1 300 Multiple Choices";
174 case Response::UseProxy:
175 ret =
"HTTP/1.1 305 Use Proxy";
177 case Response::PaymentRequired:
178 ret =
"HTTP/1.1 402 Payment Required";
180 case Response::NotAcceptable:
181 ret =
"HTTP/1.1 406 Not Acceptable";
183 case Response::ProxyAuthenticationRequired:
184 ret =
"HTTP/1.1 407 Proxy Authentication Required";
186 case Response::Conflict:
187 ret =
"HTTP/1.1 409 Conflict";
190 ret =
"HTTP/1.1 410 Gone";
192 case Response::LengthRequired:
193 ret =
"HTTP/1.1 411 Length Required";
195 case Response::PreconditionFailed:
196 ret =
"HTTP/1.1 412 Precondition Failed";
198 case Response::RequestEntityTooLarge:
199 ret =
"HTTP/1.1 413 Request Entity Too Large";
201 case Response::RequestURITooLong:
202 ret =
"HTTP/1.1 414 Request-URI Too Long";
204 case Response::UnsupportedMediaType:
205 ret =
"HTTP/1.1 415 Unsupported Media Type";
207 case Response::RequestedRangeNotSatisfiable:
208 ret =
"HTTP/1.1 416 Requested Range Not Satisfiable";
210 case Response::ExpectationFailed:
211 ret =
"HTTP/1.1 417 Expectation Failed";
213 case Response::NotImplemented:
214 ret =
"HTTP/1.1 501 Not Implemented";
216 case Response::BadGateway:
217 ret =
"HTTP/1.1 502 Bad Gateway";
219 case Response::ServiceUnavailable:
220 ret =
"HTTP/1.1 503 Service Unavailable";
222 case Response::MultiStatus:
223 ret =
"HTTP/1.1 207 Multi-Status";
225 case Response::GatewayTimeout:
226 ret =
"HTTP/1.1 504 Gateway Timeout";
228 case Response::HTTPVersionNotSupported:
229 ret =
"HTTP/1.1 505 HTTP Version Not Supported";
231 case Response::BandwidthLimitExceeded:
232 ret =
"HTTP/1.1 509 Bandwidth Limit Exceeded";
240 *len = int(strlen(ret));
248 return d->app->defaultHeaders();
254 d->app->handleRequest(request);
266 return d->config.value(entity).toMap();
280 qCWarning(CUTELYST_ENGINE) <<
"Failed to load INI file:" << settings.
status();
285 for (
const QString &group : groups) {
286 QVariantMap configGroup;
289 for (
const QString &key : child) {
293 ret.insert(group, configGroup);
302 QFile file(filename);
313#include "moc_engine.cpp"
The Cutelyst application.
static QVariantMap loadJsonConfig(const QString &filename)
Engine(Application *app, int workerCore, const QVariantMap &opts)
bool postForkApplication()
void setConfig(const QVariantMap &config)
void processRequestAsync(Cutelyst::EngineRequest *request)
static const char * httpStatusMessage(quint16 status, int *len=nullptr)
void processRequest(EngineRequest *request)
QVariantMap config(const QString &entity) const
Application * app() const
Headers & defaultHeaders()
static QVariantMap loadIniConfig(const QString &filename)
The Cutelyst namespace holds all public Cutelyst API.
QByteArray number(double n, char format, int precision)
bool open(FILE *fh, QIODeviceBase::OpenMode mode, QFileDevice::FileHandleFlags handleFlags)
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
QVariant toVariant() const const
QList::iterator insert(QList::const_iterator before, QList::parameter_type value)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setObjectName(QAnyStringView name)
QThread * thread() const const
void beginGroup(QAnyStringView prefix)
QStringList childGroups() const const
QStringList childKeys() const const
QSettings::Status status() const const
QVariant value(QAnyStringView key) const const
QString number(double n, char format, int precision)
QThread * currentThread()
QMap< QString, QVariant > toMap() const const