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
[legend]

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
 

Friends

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)
inlinestaticprotected

Returns the header key in camel case form

Definition at line 160 of file engine.h.

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

This is the HTTP default response headers that each request gets

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

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

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

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

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

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)
protectedvirtual

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)
protectedvirtual

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

bool Cutelyst::Engine::initApplication ( )
protected

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

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

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

Note
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 ( )
protected

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.

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

Called by Response to manually write data