Cutelyst  1.5.0
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Cutelyst::Engine Class Referenceabstract
Inheritance diagram for Cutelyst::Engine:
Inheritance graph

Public Member Functions

 Engine (Application *app, int workerCore, const QVariantMap &opts)
Applicationapp () const
QVariantMap config (const QString &entity) const
 user configuration for the application More...
bool isZeroWorker () const
QVariantMap opts () const
virtual quint64 time ()
int workerCore () const
virtual int workerId () const =0

Protected Member Functions

HeadersdefaultHeaders ()
virtual qint64 doWrite (Context *c, const char *data, qint64 len, void *engineData)=0
void finalize (Context *c)
virtual void finalizeBody (Context *c)
virtual void finalizeCookies (Context *c)
virtual void finalizeError (Context *c)
virtual bool finalizeHeaders (Context *c)
virtual bool finalizeHeadersWrite (Context *c, quint16 status, const Headers &headers, void *engineData)=0
bool initApplication ()
 initApplication More...
bool postForkApplication ()
 postForkApplication More...
void processRequest (const EngineRequest &req)
Q_DECL_DEPRECATED void processRequest (const QString &method, const QString &path, const QByteArray &query, const QString &protocol, bool https, const QString &serverAddress, const QHostAddress &remoteAddress, quint16 remotePort, const QString &remoteUser, const Headers &headers, quint64 startOfRequest, QIODevice *body, void *requestPtr)
qint64 write (Context *c, const char *data, qint64 len, void *engineData)

Static Protected Member Functions

static void camelCaseByteArrayHeader (QByteArray &key)
static QString camelCaseHeader (const QString &headerKey)
static const char * httpStatusMessage (quint16 status, int *len=nullptr)

Protected Attributes

EnginePrivate * d_ptr


class Application
class Response

Detailed Description

Definition at line 50 of file engine.h.

Member Function Documentation

static QString Cutelyst::Engine::camelCaseHeader ( const QString &  headerKey)

Returns the header key in camel case form

Definition at line 160 of file engine.h.

QVariantMap Cutelyst::Engine::config ( const QString &  entity) const
entitythe entity you are interested in
the configuration settings
Headers& Cutelyst::Engine::defaultHeaders ( )

This is the HTTP default response headers that each request gets

void Cutelyst::Engine::finalize ( Context c)

Called by Application to deal with finalizing cookies, headers and body

virtual void Cutelyst::Engine::finalizeBody ( Context c)

Engines must reimplement this to write the response body back to the caller

virtual void Cutelyst::Engine::finalizeCookies ( Context c)

Reimplement if you need a custom way to Set-Cookie, the default implementation writes them to c->res()->headers()

virtual void Cutelyst::Engine::finalizeError ( Context c)

Engines should overwrite this if they want to to make custom error messages. Default implementation render an html with errors.

virtual bool Cutelyst::Engine::finalizeHeaders ( Context c)

Finalize the headers, and call doWriteHeader(), reimplemententions must call this first

bool Cutelyst::Engine::initApplication ( )

This method inits the application and calls init on the engine. It must be called on the engine's thread

appthe Application to init
postForkwhen true it will call postFork on the application
true if succeded
bool Cutelyst::Engine::isZeroWorker ( ) const

Returns true if this is the Zero worker, ie if workerId() == 0 and workerCore() == 0

the value returned from this function is only valid when postFork() is issued.

Definition at line 234 of file engine.h.

QVariantMap Cutelyst::Engine::opts ( ) const

Engine options

bool Cutelyst::Engine::postForkApplication ( )

Subclasses must be call after the engine forks by the worker thread, if no forking is involved it must be called once the worker thread has started.

For convenience QThread::currentThread() has it's object name set with the worker core number.

true if the engine should use this process
qint64 Cutelyst::Engine::write ( Context c,
const char *  data,
qint64  len,
void *  engineData 

Called by Response to manually write data