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

Public Types

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

Public Member Functions

void finalize ()
virtual void finalizeBody ()
virtual void finalizeCookies ()
virtual void finalizeError ()
virtual bool finalizeHeaders ()
void setPath (char *rawPath, const int len)
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)

Public Attributes

QIODevicebody
Contextcontext
Headers headers
bool isSecure
QByteArray method
QString path
QByteArray protocol
QByteArray query
QHostAddress remoteAddress
quint16 remotePort
QString remoteUser
QByteArray serverAddress
TimePointSteady startOfRequest
Status status

Protected Member Functions

virtual qint64 doWrite (const char *data, qint64 len)=0
virtual void processingFinished ()
virtual bool webSocketHandshakeDo (const QByteArray &key, const QByteArray &origin, const QByteArray &protocol)
virtual bool writeHeaders (quint16 status, const Headers &headers)=0

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

◆ ~EngineRequest()

EngineRequest::~EngineRequest ( )
virtual

Definition at line 22 of file enginerequest.cpp.

Member Function Documentation

◆ doWrite()

virtual qint64 Cutelyst::EngineRequest::doWrite ( const char * data,
qint64 len )
protectedpure virtual

Reimplement this to do the RAW writing to the client

Implemented in Cutelyst::H2Stream, Cutelyst::ProtoRequestFastCGI, and Cutelyst::ProtoRequestHttp.

References processingFinished().

Referenced by finalizeBody(), and write().

◆ finalize()

void EngineRequest::finalize ( )

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

Definition at line 80 of file enginerequest.cpp.

References context, finalizeBody(), finalizeError(), finalizeHeaders(), processingFinished(), and status.

◆ finalizeBody()

void EngineRequest::finalizeBody ( )
virtual

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

Definition at line 27 of file enginerequest.cpp.

References body, Cutelyst::Response::body(), Cutelyst::Response::bodyDevice(), QByteArray::constData(), context, doWrite(), QByteArray::size(), status, and write().

Referenced by finalize().

◆ finalizeCookies()

void EngineRequest::finalizeCookies ( )
virtual

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

Definition at line 94 of file enginerequest.cpp.

References context, Cutelyst::Response::cookies(), headers, and Cutelyst::Response::headers().

Referenced by finalizeHeaders().

◆ finalizeError()

void EngineRequest::finalizeError ( )
virtual

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

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

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

Definition at line 104 of file enginerequest.cpp.

References context, finalizeCookies(), headers, Cutelyst::Response::headers(), Cutelyst::Response::size(), status, Cutelyst::Response::status(), and writeHeaders().

Referenced by finalize().

◆ processingFinished()

void EngineRequest::processingFinished ( )
protectedvirtual

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.

Default implementation deletes both body and context.

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

Reimplemented in Cutelyst::H2Stream, Cutelyst::ProtoRequestFastCGI, and Cutelyst::ProtoRequestHttp.

Definition at line 188 of file enginerequest.cpp.

Referenced by doWrite(), and finalize().

◆ setPath() [1/2]

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

This method sets the path and already does the decoding so that it is done a single time.

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

Definition at line 202 of file enginerequest.cpp.

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

Referenced by writeHeaders().

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

◆ webSocketHandshake()

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

Definition at line 144 of file enginerequest.cpp.

◆ webSocketHandshakeDo()

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

Definition at line 192 of file enginerequest.cpp.

◆ webSocketSendBinaryMessage()

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

Definition at line 169 of file enginerequest.cpp.

◆ webSocketSendPing()

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

Definition at line 175 of file enginerequest.cpp.

◆ webSocketSendTextMessage()

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

Definition at line 163 of file enginerequest.cpp.

◆ write()

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

◆ writeHeaders()

virtual bool Cutelyst::EngineRequest::writeHeaders ( quint16 status,
const Headers & headers )
protectedpure virtual

Reimplement this to write the headers back to the client

Implemented in Cutelyst::H2Stream, Cutelyst::ProtoRequestFastCGI, and Cutelyst::ProtoRequestHttp.

References headers, path, protocol, setPath(), and status.

Referenced by finalizeHeaders().

◆ Engine

friend class Engine
friend

Definition at line 30 of file enginerequest.h.

Member Data Documentation

◆ body

QIODevice* Cutelyst::EngineRequest::body

The QIODevice containing the body (if any) of the request

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

The Cutelyst::Context of this request

Note
It's deleted on processingFinished() or destructor

Definition at line 173 of file enginerequest.h.

Referenced by finalize(), finalizeBody(), finalizeCookies(), finalizeError(), finalizeHeaders(), and Cutelyst::Application::handleRequest().

◆ headers

◆ isSecure

bool Cutelyst::EngineRequest::isSecure

If the connection is secure HTTPS

Definition at line 185 of file enginerequest.h.

◆ method

QByteArray Cutelyst::EngineRequest::method

The method used (GET, POST...)

Definition at line 142 of file enginerequest.h.

◆ path

QString Cutelyst::EngineRequest::path

Call setPath() instead

Definition at line 145 of file enginerequest.h.

Referenced by setPath(), and writeHeaders().

◆ protocol

QByteArray Cutelyst::EngineRequest::protocol

The protocol requested by the user agent 'HTTP1/1'

Definition at line 151 of file enginerequest.h.

Referenced by writeHeaders(), and Cutelyst::ProtoRequestHttp::writeHeaders().

◆ query

QByteArray Cutelyst::EngineRequest::query

The query string requested by the user agent 'foo=bar&baz'

Definition at line 148 of file enginerequest.h.

◆ remoteAddress

QHostAddress Cutelyst::EngineRequest::remoteAddress

The remote/client address

Definition at line 159 of file enginerequest.h.

◆ remotePort

quint16 Cutelyst::EngineRequest::remotePort

The remote/client port

Definition at line 179 of file enginerequest.h.

◆ remoteUser

QString Cutelyst::EngineRequest::remoteUser

The remote user name set by a front web server

Definition at line 162 of file enginerequest.h.

◆ serverAddress

QByteArray Cutelyst::EngineRequest::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

Definition at line 156 of file enginerequest.h.

◆ startOfRequest

TimePointSteady Cutelyst::EngineRequest::startOfRequest

The timepoint of the start of request

Definition at line 176 of file enginerequest.h.

◆ status