cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst::EngineRequest Class Referenceabstract

Public Types

enum  StatusFlag {
  InitialState , FinalizedHeaders , IOWrite , Chunked ,
  ChunkedDone , Async , Finalized
}

Public Member Functions

void finalize ()
 Called by Application to deal with finalizing cookies, headers and body.
virtual void finalizeBody ()
 Engines must reimplement this to write the response body back to the caller.
virtual void finalizeCookies ()
 Reimplement if you need a custom way to Set-Cookie, the default implementation writes them to c->res()->headers().
virtual void finalizeError ()
 Engines should overwrite this if they want to to make custom error messages.
virtual bool finalizeHeaders ()
 Finalize the headers, and call doWriteHeader(), reimplemententions must call this first.
void setPath (char *rawPath, const int len)
 This method sets the path and already does the decoding so that it is done a single time.
void setPath (const QString &path)
virtual bool webSocketClose (quint16 code, const QString &reason)
bool webSocketHandshake (const QString &key, const QString &origin, const QString &protocol)
virtual bool webSocketSendBinaryMessage (const QByteArray &message)
virtual bool webSocketSendPing (const QByteArray &payload)
virtual bool webSocketSendTextMessage (const QString &message)
qint64 write (const char *data, qint64 len)
 Called by Response to manually write data.

Public Attributes

QIODevicebody
 The QIODevice containing the body (if any) of the request.
Contextcontext
 The Cutelyst::Context of this request.
QElapsedTimer elapsed
 The elapsed timer since the start of request.
Headers headers
 The request headers.
bool isSecure
 If the connection is secure HTTPS.
QString method
 The method used (GET, POST...).
QString path
 Call setPath() instead.
QString protocol
 The protocol requested by the user agent 'HTTP1/1'.
QByteArray query
 The query string requested by the user agent 'foo=bar&baz'.
QHostAddress remoteAddress
 The remote/client address.
quint16 remotePort
 The remote/client port.
QString remoteUser
 The remote user name set by a front web server.
QString serverAddress
 The server address which the server is listening to, usually the 'Host' header but if that's not present should be filled with the server address.
quint64 startOfRequest
 The timestamp of the start of request, TODO remove in Cutelyst 3.
Status status
 Connection status.

Protected Member Functions

virtual qint64 doWrite (const char *data, qint64 len)=0
 Reimplement this to do the RAW writing to the client.
virtual void processingFinished ()
 This is called when the Application chain is finished processing this request, here the request can send final bytes to the client or do a clean up.
virtual bool webSocketHandshakeDo (const QString &key, const QString &origin, const QString &protocol)
virtual bool writeHeaders (quint16 status, const Headers &headers)=0
 Reimplement this to write the headers back to the client.

Friends

class Engine

Detailed Description

Definition at line 25 of file enginerequest.h.

Member Enumeration Documentation

◆ StatusFlag

enum Cutelyst::EngineRequest::StatusFlag

Definition at line 31 of file enginerequest.h.

Constructor & Destructor Documentation

◆ EngineRequest()

EngineRequest::EngineRequest ( )
explicit

Definition at line 17 of file enginerequest.cpp.

◆ ~EngineRequest()

EngineRequest::~EngineRequest ( )
virtual

Definition at line 21 of file enginerequest.cpp.

Member Function Documentation

◆ finalize()

void EngineRequest::finalize ( )

◆ finalizeBody()

void EngineRequest::finalizeBody ( )
virtual

◆ finalizeCookies()

void EngineRequest::finalizeCookies ( )
virtual

◆ finalizeError()

void EngineRequest::finalizeError ( )
virtual

Default implementation render an html with errors.

Definition at line 59 of file enginerequest.cpp.

References body, context, Cutelyst::Response::setBody(), Cutelyst::Response::setContentType(), and Cutelyst::Response::setStatus().

Referenced by finalize().

◆ finalizeHeaders()

bool EngineRequest::finalizeHeaders ( )
virtual

◆ processingFinished()

void EngineRequest::processingFinished ( )
protectedvirtual

Default implementation deletes both body and context.

If a WebSocket upgrade was made then you will want to keep the context object around.

Definition at line 195 of file enginerequest.cpp.

Referenced by doWrite(), and finalize().

◆ setPath() [1/2]

void EngineRequest::setPath ( char * rawPath,
const int len )

The path requested by the user agent '/index', MUST NOT have a leading slash

Definition at line 209 of file enginerequest.cpp.

References QString::fromLatin1(), QString::fromUtf8(), and path.

Referenced by writeHeaders().

◆ setPath() [2/2]

void Cutelyst::EngineRequest::setPath ( const QString & path)
inline

Definition at line 130 of file enginerequest.h.

◆ webSocketClose()

bool EngineRequest::webSocketClose ( quint16 code,
const QString & reason )
virtual

Definition at line 188 of file enginerequest.cpp.

◆ webSocketHandshake()

bool EngineRequest::webSocketHandshake ( const QString & key,
const QString & origin,
const QString & protocol )

Definition at line 151 of file enginerequest.cpp.

◆ webSocketHandshakeDo()

bool EngineRequest::webSocketHandshakeDo ( const QString & key,
const QString & origin,
const QString & protocol )
protectedvirtual

Definition at line 199 of file enginerequest.cpp.

◆ webSocketSendBinaryMessage()

bool EngineRequest::webSocketSendBinaryMessage ( const QByteArray & message)
virtual

Definition at line 176 of file enginerequest.cpp.

◆ webSocketSendPing()

bool EngineRequest::webSocketSendPing ( const QByteArray & payload)
virtual

Definition at line 182 of file enginerequest.cpp.

◆ webSocketSendTextMessage()

bool EngineRequest::webSocketSendTextMessage ( const QString & message)
virtual

Definition at line 170 of file enginerequest.cpp.

◆ write()

qint64 EngineRequest::write ( const char * data,
qint64 len )

◆ Engine

friend class Engine
friend

Definition at line 28 of file enginerequest.h.

Member Data Documentation

◆ body

QIODevice* Cutelyst::EngineRequest::body
Note
It's deleted when Context gets deleted

Definition at line 170 of file enginerequest.h.

Referenced by Cutelyst::Request::Request(), finalizeBody(), and finalizeError().

◆ context

Context* Cutelyst::EngineRequest::context

◆ elapsed

QElapsedTimer Cutelyst::EngineRequest::elapsed

Definition at line 183 of file enginerequest.h.

◆ headers

Headers Cutelyst::EngineRequest::headers

Definition at line 160 of file enginerequest.h.

Referenced by finalizeCookies(), finalizeHeaders(), and writeHeaders().

◆ isSecure

bool Cutelyst::EngineRequest::isSecure

Definition at line 180 of file enginerequest.h.

◆ method

QString Cutelyst::EngineRequest::method

Definition at line 137 of file enginerequest.h.

◆ path

QString Cutelyst::EngineRequest::path

Definition at line 140 of file enginerequest.h.

Referenced by setPath(), and writeHeaders().

◆ protocol

QString Cutelyst::EngineRequest::protocol

Definition at line 146 of file enginerequest.h.

Referenced by writeHeaders().

◆ query

QByteArray Cutelyst::EngineRequest::query

Definition at line 143 of file enginerequest.h.

◆ remoteAddress

QHostAddress Cutelyst::EngineRequest::remoteAddress

Definition at line 154 of file enginerequest.h.

◆ remotePort

quint16 Cutelyst::EngineRequest::remotePort

Definition at line 177 of file enginerequest.h.

◆ remoteUser

QString Cutelyst::EngineRequest::remoteUser

Definition at line 157 of file enginerequest.h.

◆ serverAddress

QString Cutelyst::EngineRequest::serverAddress

Definition at line 151 of file enginerequest.h.

◆ startOfRequest

quint64 Cutelyst::EngineRequest::startOfRequest

Definition at line 163 of file enginerequest.h.

◆ status

Status Cutelyst::EngineRequest::status