cutelyst 4.0.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
Cutelyst::EngineRequest Class Referenceabstract

Public Types

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

Public Member Functions

void finalize ()
 Called by Application to deal with finalizing cookies, headers and body. More...
 
virtual void finalizeBody ()
 Engines must reimplement this to write the response body back to the caller. More...
 
virtual void finalizeCookies ()
 Reimplement if you need a custom way to Set-Cookie, the default implementation writes them to c->res()->headers() More...
 
virtual void finalizeError ()
 Engines should overwrite this if they want to to make custom error messages. More...
 
virtual bool finalizeHeaders ()
 Finalize the headers, and call doWriteHeader(), reimplemententions must call this first. More...
 
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. More...
 
void setPath (QByteArray &path)
 
virtual bool webSocketClose (quint16 code, const QString &reason)
 
bool webSocketHandshake (const QByteArray &key, const QByteArray &origin, const QByteArray &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. More...
 

Public Attributes

QIODevice * body
 The QIODevice containing the body (if any) of the request. More...
 
Contextcontext
 The Cutelyst::Context of this request. More...
 
Headers headers
 The request headers. More...
 
bool isSecure
 If the connection is secure HTTPS. More...
 
QByteArray method
 The method used (GET, POST...) More...
 
QString path
 Call setPath() instead. More...
 
QByteArray protocol
 The protocol requested by the user agent 'HTTP1/1'. More...
 
QByteArray query
 The query string requested by the user agent 'foo=bar&baz'. More...
 
QHostAddress remoteAddress
 The remote/client address. More...
 
quint16 remotePort
 The remote/client port. More...
 
QString remoteUser
 The remote user name set by a front web server. More...
 
QByteArray 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. More...
 
TimePointSteady startOfRequest
 The timepoint of the start of request. More...
 
Status status
 Connection status. More...
 

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. More...
 
virtual bool webSocketHandshakeDo (const QByteArray &key, const QByteArray &origin, const QByteArray &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 27 of file enginerequest.h.

Member Enumeration Documentation

◆ StatusFlag

enum Cutelyst::EngineRequest::StatusFlag : quint8

Definition at line 33 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

◆ 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 189 of file enginerequest.cpp.

Referenced by finalize().

◆ setPath() [1/2]

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

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

Definition at line 203 of file enginerequest.cpp.

References path.

◆ setPath() [2/2]

void Cutelyst::EngineRequest::setPath ( QByteArray &  path)
inline

Definition at line 135 of file enginerequest.h.

◆ webSocketClose()

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

Definition at line 182 of file enginerequest.cpp.

◆ webSocketHandshake()

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

Definition at line 145 of file enginerequest.cpp.

◆ webSocketHandshakeDo()

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

Definition at line 193 of file enginerequest.cpp.

◆ webSocketSendBinaryMessage()

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

Definition at line 170 of file enginerequest.cpp.

◆ webSocketSendPing()

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

Definition at line 176 of file enginerequest.cpp.

◆ webSocketSendTextMessage()

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

Definition at line 164 of file enginerequest.cpp.

◆ write()

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

Definition at line 123 of file enginerequest.cpp.

References doWrite(), and status.

Referenced by finalizeBody().

Friends And Related Function Documentation

◆ Engine

friend class Engine
friend

Definition at line 30 of file enginerequest.h.

Member Data Documentation

◆ body

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

Definition at line 169 of file enginerequest.h.

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

◆ context

Context* Cutelyst::EngineRequest::context

◆ headers

Headers Cutelyst::EngineRequest::headers

Definition at line 165 of file enginerequest.h.

Referenced by finalizeCookies(), and finalizeHeaders().

◆ isSecure

bool Cutelyst::EngineRequest::isSecure

Definition at line 185 of file enginerequest.h.

◆ method

QByteArray Cutelyst::EngineRequest::method

Definition at line 142 of file enginerequest.h.

◆ path

QString Cutelyst::EngineRequest::path

Definition at line 145 of file enginerequest.h.

Referenced by setPath().

◆ protocol

QByteArray Cutelyst::EngineRequest::protocol

Definition at line 151 of file enginerequest.h.

◆ query

QByteArray Cutelyst::EngineRequest::query

Definition at line 148 of file enginerequest.h.

◆ remoteAddress

QHostAddress Cutelyst::EngineRequest::remoteAddress

Definition at line 159 of file enginerequest.h.

◆ remotePort

quint16 Cutelyst::EngineRequest::remotePort

Definition at line 179 of file enginerequest.h.

◆ remoteUser

QString Cutelyst::EngineRequest::remoteUser

Definition at line 162 of file enginerequest.h.

◆ serverAddress

QByteArray Cutelyst::EngineRequest::serverAddress

Definition at line 156 of file enginerequest.h.

◆ startOfRequest

TimePointSteady Cutelyst::EngineRequest::startOfRequest

Definition at line 176 of file enginerequest.h.

◆ status

Status Cutelyst::EngineRequest::status