cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
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 | |
QIODevice * | body |
Context * | context |
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 |
Definition at line 27 of file enginerequest.h.
enum Cutelyst::EngineRequest::StatusFlag : quint8 |
Definition at line 33 of file enginerequest.h.
|
explicit |
Definition at line 17 of file enginerequest.cpp.
|
virtual |
Definition at line 21 of file enginerequest.cpp.
|
protectedpure virtual |
Reimplement this to do the RAW writing to the client
Implemented in Cutelyst::ProtoRequestFastCGI, Cutelyst::ProtoRequestHttp, and Cutelyst::H2Stream.
Referenced by finalizeBody(), and write().
void EngineRequest::finalize | ( | ) |
Called by Application to deal with finalizing cookies, headers and body
Definition at line 79 of file enginerequest.cpp.
References context, Cutelyst::Context::error(), finalizeBody(), finalizeError(), finalizeHeaders(), processingFinished(), and status.
|
virtual |
Engines must reimplement this to write the response body back to the caller
Definition at line 26 of file enginerequest.cpp.
References QIODevice::atEnd(), body, Cutelyst::Response::body(), Cutelyst::Response::bodyDevice(), QByteArray::constData(), context, doWrite(), QIODevice::isSequential(), QIODevice::read(), Cutelyst::Context::response(), QIODevice::seek(), QByteArray::size(), status, and write().
Referenced by finalize().
|
virtual |
Reimplement if you need a custom way to Set-Cookie, the default implementation writes them to c->res()->headers()
Definition at line 93 of file enginerequest.cpp.
References context, Cutelyst::Response::cookies(), headers, Cutelyst::Response::headers(), Cutelyst::Headers::pushHeader(), and Cutelyst::Context::response().
Referenced by finalizeHeaders().
|
virtual |
Engines should overwrite this if they want to to make custom error messages. Default implementation render an html with errors.
Definition at line 59 of file enginerequest.cpp.
References body, context, Cutelyst::Context::errors(), QStringList::join(), Cutelyst::Context::response(), Cutelyst::Response::setBody(), Cutelyst::Response::setContentType(), and Cutelyst::Response::setStatus().
Referenced by finalize().
|
virtual |
Finalize the headers, and call doWriteHeader(), reimplemententions must call this first
Definition at line 103 of file enginerequest.cpp.
References context, finalizeCookies(), headers, Cutelyst::Response::headers(), Cutelyst::Context::response(), Cutelyst::Headers::setContentLength(), Cutelyst::Response::size(), status, Cutelyst::Response::status(), and writeHeaders().
Referenced by finalize().
|
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::ProtoRequestFastCGI, Cutelyst::ProtoRequestHttp, and Cutelyst::H2Stream.
Definition at line 187 of file enginerequest.cpp.
Referenced by finalize().
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 201 of file enginerequest.cpp.
References QString::fromLatin1(), QString::fromUtf8(), path, QString::prepend(), and QString::startsWith().
|
inline |
Definition at line 135 of file enginerequest.h.
|
virtual |
Definition at line 180 of file enginerequest.cpp.
bool EngineRequest::webSocketHandshake | ( | const QByteArray & | key, |
const QByteArray & | origin, | ||
const QByteArray & | protocol | ||
) |
Definition at line 143 of file enginerequest.cpp.
|
protectedvirtual |
Definition at line 191 of file enginerequest.cpp.
|
virtual |
Definition at line 168 of file enginerequest.cpp.
|
virtual |
Definition at line 174 of file enginerequest.cpp.
|
virtual |
Definition at line 162 of file enginerequest.cpp.
qint64 EngineRequest::write | ( | const char * | data, |
qint64 | len | ||
) |
Called by Response to manually write data
Definition at line 121 of file enginerequest.cpp.
References QByteArray::append(), QByteArray::data(), doWrite(), QByteArray::number(), QByteArray::reserve(), QByteArray::size(), status, and QByteArray::toUpper().
Referenced by finalizeBody().
|
protectedpure virtual |
Reimplement this to write the headers back to the client
Implemented in Cutelyst::ProtoRequestFastCGI, Cutelyst::ProtoRequestHttp, and Cutelyst::H2Stream.
Referenced by finalizeHeaders().
|
friend |
Definition at line 30 of file enginerequest.h.
QIODevice* Cutelyst::EngineRequest::body |
The QIODevice containing the body (if any) of the request
Definition at line 169 of file enginerequest.h.
Referenced by Cutelyst::Request::Request(), finalizeBody(), and finalizeError().
Context* Cutelyst::EngineRequest::context |
The Cutelyst::Context of this request
Definition at line 173 of file enginerequest.h.
Referenced by finalize(), finalizeBody(), finalizeCookies(), finalizeError(), finalizeHeaders(), and Cutelyst::Application::handleRequest().
Headers Cutelyst::EngineRequest::headers |
The request headers
Definition at line 165 of file enginerequest.h.
Referenced by finalizeCookies(), finalizeHeaders(), Cutelyst::ProtoRequestFastCGI::writeHeaders(), Cutelyst::ProtoRequestHttp::writeHeaders(), and Cutelyst::H2Stream::writeHeaders().
bool Cutelyst::EngineRequest::isSecure |
If the connection is secure HTTPS
Definition at line 185 of file enginerequest.h.
QByteArray Cutelyst::EngineRequest::method |
The method used (GET, POST...)
Definition at line 142 of file enginerequest.h.
QString Cutelyst::EngineRequest::path |
QByteArray Cutelyst::EngineRequest::protocol |
The protocol requested by the user agent 'HTTP1/1'
Definition at line 151 of file enginerequest.h.
Referenced by Cutelyst::ProtoRequestHttp::writeHeaders().
QByteArray Cutelyst::EngineRequest::query |
The query string requested by the user agent 'foo=bar&baz'
Definition at line 148 of file enginerequest.h.
QHostAddress Cutelyst::EngineRequest::remoteAddress |
The remote/client address
Definition at line 159 of file enginerequest.h.
quint16 Cutelyst::EngineRequest::remotePort |
The remote/client port
Definition at line 179 of file enginerequest.h.
QString Cutelyst::EngineRequest::remoteUser |
The remote user name set by a front web server
Definition at line 162 of file enginerequest.h.
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.
TimePointSteady Cutelyst::EngineRequest::startOfRequest |
The timepoint of the start of request
Definition at line 176 of file enginerequest.h.
Status Cutelyst::EngineRequest::status |
Connection status
Definition at line 182 of file enginerequest.h.
Referenced by finalize(), finalizeBody(), finalizeHeaders(), Cutelyst::Application::handleRequest(), Cutelyst::ProtoRequestFastCGI::processingFinished(), Cutelyst::ProtoRequestHttp::processingFinished(), write(), Cutelyst::ProtoRequestFastCGI::writeHeaders(), Cutelyst::ProtoRequestHttp::writeHeaders(), and Cutelyst::H2Stream::writeHeaders().