|
Cutelyst
3.5.0
|

Signals | |
| void | webSocketBinaryFrame (const QByteArray &message, bool isLastFrame, Cutelyst::Context *c) |
| Emitted when the websocket receives a binary frame, this is usefull for parsing big chunks of data without waiting till the whole message arives. | |
| void | webSocketBinaryMessage (const QByteArray &message, Cutelyst::Context *c) |
| Emitted when the websocket receives a binary message, this accounts for all binary frames till the last one. | |
| void | webSocketClosed (quint16 closeCode, const QString &reason) |
| Emitted when the websocket receives a close frame, including a close code and a reason, it's also emitted when the connection closes without the client sending the close frame. More... | |
| void | webSocketPong (const QByteArray &payload, Cutelyst::Context *c) |
| Emitted when the websocket receives a pong frame, which might include a payload. | |
| void | webSocketTextFrame (const QString &message, bool isLastFrame, Cutelyst::Context *c) |
| Emitted when the websocket receives a text frame, this is usefull for parsing big chunks of data without waiting till the whole message arives. | |
| void | webSocketTextMessage (const QString &message, Cutelyst::Context *c) |
| Emitted when the websocket receives a text message, this accounts for all text frames till the last one. | |
Public Member Functions | |
| Request (EngineRequest *engineRequest) | |
| QHostAddress | address () const noexcept |
| QString | addressString () const |
| QStringList | args () const |
| QStringList | arguments () const noexcept |
| QString | base () const |
| QIODevice * | body () const |
| QVariant | bodyData () const |
| QJsonArray | bodyJsonArray () const |
| QJsonDocument | bodyJsonDocument () const |
| QJsonObject | bodyJsonObject () const |
| QString | bodyParam (const QString &key, const QString &defaultValue={}) const |
| QString | bodyParameter (const QString &key, const QString &defaultValue={}) const |
| ParamsMultiMap | bodyParameters () const |
| QStringList | bodyParameters (const QString &key) const |
| QVariantMap | bodyParametersVariant () const |
| ParamsMultiMap | bodyParams () const |
| QStringList | bodyParams (const QString &key) const |
| QStringList | captures () const noexcept |
| QString | contentEncoding () const |
| QString | contentType () const |
| QString | cookie (const QString &name) const |
| QStringList | cookies (const QString &name) const |
| ParamsMultiMap | cookies () const |
| Engine * | engine () const noexcept |
| QString | header (const QString &key) const |
| Headers | headers () const noexcept |
| QString | hostname () const |
| bool | isDelete () const noexcept |
| bool | isGet () const noexcept |
| bool | isHead () const noexcept |
| bool | isPatch () const noexcept |
| bool | isPost () const noexcept |
| bool | isPut () const noexcept |
| ParamsMultiMap | mangleParams (const ParamsMultiMap &args, bool append=false) const |
| QString | match () const noexcept |
| QString | method () const noexcept |
| QString | path () const noexcept |
| quint16 | port () const |
| QString | protocol () const noexcept |
| QString | queryKeywords () const |
| QString | queryParam (const QString &key, const QString &defaultValue={}) const |
| QString | queryParameter (const QString &key, const QString &defaultValue={}) const |
| ParamsMultiMap | queryParameters () const |
| QStringList | queryParameters (const QString &key) const |
| QVariantMap | queryParametersVariant () const |
| ParamsMultiMap | queryParams () const |
| QStringList | queryParams (const QString &key) const |
| QString | referer () const |
| QString | remoteUser () const noexcept |
| bool | secure () const noexcept |
| void | setArguments (const QStringList &arguments) |
| void | setCaptures (const QStringList &captures) |
| void | setMatch (const QString &match) |
| Upload * | upload (const QString &name) const |
| QVector< Upload * > | uploads () const |
| Uploads | uploads (const QString &name) const |
| QMultiMap< QString, Upload * > | uploadsMap () const |
| QUrl | uri () const |
| QUrl | uriWith (const ParamsMultiMap &args, bool append=false) const |
| QString | userAgent () const |
| bool | xhr () const noexcept |
Public Member Functions inherited from QObject | |
| QObject (QObject *parent) | |
| bool | blockSignals (bool block) |
| const QObjectList & | children () const const |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
| void | deleteLater () |
| void | destroyed (QObject *obj) |
| bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
| bool | disconnect (const QObject *receiver, const char *method) const const |
| void | dumpObjectInfo () const const |
| void | dumpObjectInfo () |
| void | dumpObjectTree () const const |
| void | dumpObjectTree () |
| QList< QByteArray > | dynamicPropertyNames () const const |
| virtual bool | event (QEvent *e) |
| virtual bool | eventFilter (QObject *watched, QEvent *event) |
| T | findChild (const QString &name, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
| bool | inherits (const char *className) const const |
| void | installEventFilter (QObject *filterObj) |
| bool | isWidgetType () const const |
| bool | isWindowType () const const |
| void | killTimer (int id) |
| virtual const QMetaObject * | metaObject () const const |
| void | moveToThread (QThread *targetThread) |
| QString | objectName () const const |
| void | objectNameChanged (const QString &objectName) |
| QObject * | parent () const const |
| QVariant | property (const char *name) const const |
| virtual int | qt_metacall (QMetaObject::Call, int, void **) |
| virtual void * | qt_metacast (const char *) |
| void | removeEventFilter (QObject *obj) |
| void | setObjectName (const QString &name) |
| void | setParent (QObject *parent) |
| bool | setProperty (const char *name, const QVariant &value) |
| bool | signalsBlocked () const const |
| int | startTimer (int interval, Qt::TimerType timerType) |
| int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
| QThread * | thread () const const |
Properties | |
| QStringList | args |
| QStringList | arguments |
| QString | base |
| QVariant | bodyData |
| Cutelyst::ParamsMultiMap | bodyParams |
| QString | contentEncoding |
| QString | contentType |
| QString | hostname |
| QString | match |
| QString | method |
| QString | path |
| quint16 | port |
| QString | protocol |
| Cutelyst::ParamsMultiMap | queryParams |
| QString | referer |
| QString | remoteUser |
| bool | secure |
| QUrl | uri |
| QString | userAgent |
Properties inherited from QObject | |
| objectName | |
Friends | |
| class | Application |
| class | Context |
| class | Dispatcher |
| class | DispatchType |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
| bool | disconnect (const QMetaObject::Connection &connection) |
| bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
| bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
| bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
| QString | tr (const char *sourceText, const char *disambiguation, int n) |
| QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions inherited from QObject | |
| virtual void | childEvent (QChildEvent *event) |
| virtual void | connectNotify (const QMetaMethod &signal) |
| virtual void | customEvent (QEvent *event) |
| virtual void | disconnectNotify (const QMetaMethod &signal) |
| bool | isSignalConnected (const QMetaMethod &signal) const const |
| int | receivers (const char *signal) const const |
| QObject * | sender () const const |
| int | senderSignalIndex () const const |
| virtual void | timerEvent (QTimerEvent *event) |
| Request::Request | ( | Cutelyst::EngineRequest * | engineRequest | ) |
Constructs a new Request object.
Definition at line 19 of file request.cpp.
References Cutelyst::EngineRequest::body.
|
noexcept |
Returns the address of the client
Definition at line 33 of file request.cpp.
| QString Request::addressString | ( | ) | const |
Returns the address as string of the client.
When using IPv6 sockets to listen to both IPv4 and IPv6 sockets the output of QHostAddress might be something like "::ffff:127.0.0.1", which is not a bug and a valid address, but from an application point of view this might not be interesting to have, so this function checks if it's possible to convert to an IPv4 address and returns "127.0.0.1".
Definition at line 39 of file request.cpp.
References QHostAddress::toString().
|
inline |
Shortcut for arguments()
Referenced by mangleParams(), and uriWith().
|
noexcept |
Returns a list of string containing the arguments. For example, if your action was
and the URI for the request was http://.../foo/bar/bah, the string bah would be the first and only argument.
Arguments get automatically URI-unescaped for you.
Referenced by setArguments().
| QString Cutelyst::Request::base | ( | ) | const |
Returns Contains the URI base. This will always have a trailing slash. Note that the URI scheme (e.g., http vs. https) must be determined through heuristics; depending on your server configuration, it may be incorrect. See secure() for more info.
If your application was queried with the URI http://localhost:3000/some/path then base is http://localhost:3000/.
| QIODevice * Request::body | ( | ) | const |
Returns the message body of the request as passed by the Engine, this can even be a file if the Engine wants to.
Definition at line 179 of file request.cpp.
Referenced by Cutelyst::Context::Context().
| QVariant Cutelyst::Request::bodyData | ( | ) | const |
Returns a QVariant representation of POST/PUT body data that is not classic HTML form data, such as JSON, XML, etc. By default, Cutelyst will parse incoming data of the type 'application/json' and return access to that data via this method.
You may define addition data_handlers.
If the POST is malformed in some way (such as undefined or not content that matches the content-type) we return a null QVariant.
If the POSTed content type does not match an available data handler, this will also return a null QVariant.
Referenced by bodyJsonArray(), bodyJsonDocument(), and bodyJsonObject().
| QJsonArray Request::bodyJsonArray | ( | ) | const |
When request Content-Type is 'application/json' this will contain the parsed JSON representation array.
Definition at line 204 of file request.cpp.
References QJsonDocument::array(), bodyData(), and QVariant::toJsonDocument().
| QJsonDocument Request::bodyJsonDocument | ( | ) | const |
When request Content-Type is 'application/json' this will contain the parsed JSON representation document.
Definition at line 194 of file request.cpp.
References bodyData(), and QVariant::toJsonDocument().
| QJsonObject Request::bodyJsonObject | ( | ) | const |
When request Content-Type is 'application/json' this will contain the parsed JSON representation object.
Definition at line 199 of file request.cpp.
References bodyData(), QJsonDocument::object(), and QVariant::toJsonDocument().
|
inline |
Convenience method for geting a single body value passing a key and an optional default value
Definition at line 530 of file request.h.
References bodyParameters(), and QMap::value().
|
inline |
Convenience method for geting a single body value passing a key and an optional default value
Definition at line 524 of file request.h.
References bodyParameters(), and QMap::value().
| ParamsMultiMap Request::bodyParameters | ( | ) | const |
Returns a Map of body (POST/PUT) parameters when content type is application/x-www-form-urlencoded
Definition at line 214 of file request.cpp.
Referenced by bodyParam(), bodyParameter(), bodyParameters(), bodyParametersVariant(), bodyParams(), and Cutelyst::Validator::validate().
| QStringList Request::bodyParameters | ( | const QString & | key | ) | const |
Convenience method for geting all body values passing a key
Definition at line 223 of file request.cpp.
References bodyParameters(), QMap::constEnd(), QMultiMap::constFind(), QMap::const_iterator::key(), and QList::prepend().
| QVariantMap Request::bodyParametersVariant | ( | ) | const |
Returns a QVariantMap of body (POST/PUT) parameters, this method is expensive as it creates the map each time it's called, cache it's result instead of calling multiple times
Definition at line 209 of file request.cpp.
References bodyParameters().
|
inline |
Short for bodyParameters()
|
inline |
Convenience method for geting all body values passing a key
Definition at line 533 of file request.h.
References bodyParameters().
|
noexcept |
Captures
Definition at line 161 of file request.cpp.
Referenced by Cutelyst::ActionChain::doExecute(), and setCaptures().
|
inline |
Returns the Content-Encoding header
|
inline |
Returns the Content-Type header
Returns the cookie with the given name
Definition at line 272 of file request.cpp.
| QStringList Request::cookies | ( | const QString & | name | ) | const |
Returns a list of cookies that match with the given name
Definition at line 282 of file request.cpp.
References QList::prepend().
| Cutelyst::ParamsMultiMap Request::cookies | ( | ) | const |
Returns all the cookies from the request
Definition at line 299 of file request.cpp.
|
noexcept |
Returns the current Engine processing the requests.
Definition at line 434 of file request.cpp.
Short for headers().header(key);
Definition at line 554 of file request.h.
References Cutelyst::Headers::header(), and headers().
|
noexcept |
Returns the HTTP request headers
Definition at line 308 of file request.cpp.
Referenced by header(), and Cutelyst::ViewJson::render().
| QString Cutelyst::Request::hostname | ( | ) | const |
Returns the hostname of the client, or null if not found or an error has happened.
This functions makes blocking call to do a reverse DNS lookup if the engine didn't set the hostname.
|
noexcept |
Returns true if the request method is DELETE.
Definition at line 350 of file request.cpp.
|
noexcept |
Returns true if the request method is GET.
Definition at line 326 of file request.cpp.
|
noexcept |
Returns true if the request method is HEAD.
Definition at line 332 of file request.cpp.
Referenced by Cutelyst::RenderView::doExecute().
|
noexcept |
Returns true if the request method is PATCH.
Definition at line 344 of file request.cpp.
|
noexcept |
Returns true if the request method is POST.
Definition at line 320 of file request.cpp.
|
noexcept |
Returns true if the request method is PUT.
Definition at line 338 of file request.cpp.
| ParamsMultiMap Request::mangleParams | ( | const ParamsMultiMap & | args, |
| bool | append = false |
||
| ) | const |
Returns a ParamsMultiMap of parameters stemming from the current request's params, plus the ones supplied. Keys for which no current param exists will be added, keys with null values will be removed and keys with existing params will be replaced. Note that you can supply a true value as the final argument to change behavior with regards to existing parameters, appending values rather than replacing them.
A quick example:
versus append mode:
This is the code behind uriWith().
Definition at line 403 of file request.cpp.
References args(), QList::constBegin(), QList::constEnd(), queryParams(), QMultiMap::replace(), and QMap::unite().
Referenced by uriWith().
|
noexcept |
This contains the matching part of a Regex action. Otherwise it returns the same as 'action' (not a pointer but it's private name), except for default actions, which return an empty string.
Referenced by setMatch().
|
noexcept |
Returns the request method (GET, POST, HEAD, etc).
|
noexcept |
Returns the path, i.e. the part of the URI after base(), for the current request. for http://localhost/path/foo path will contain 'path/foo'
| quint16 Cutelyst::Request::port | ( | ) | const |
Returns the originating port of the client
|
noexcept |
Returns the protocol (HTTP/1.0 or HTTP/1.1) used for the current request.
| QString Request::queryKeywords | ( | ) | const |
Contains the keywords portion of a query string, when no '=' signs are present.
Definition at line 236 of file request.cpp.
|
inline |
Convenience method for geting a single query value passing a key and an optional default value
Definition at line 542 of file request.h.
References queryParameters(), and QMap::value().
Referenced by Cutelyst::StatusMessage::load().
|
inline |
Convenience method for geting a single query value passing a key and an optional default value
Definition at line 536 of file request.h.
References queryParameters(), and QMap::value().
| ParamsMultiMap Request::queryParameters | ( | ) | const |
Returns a QMultiHash containing the query string parameters
Definition at line 250 of file request.cpp.
Referenced by queryParam(), queryParameter(), queryParameters(), queryParametersVariant(), queryParams(), and Cutelyst::Validator::validate().
| QStringList Request::queryParameters | ( | const QString & | key | ) | const |
Convenience method for geting all query values passing a key
Definition at line 259 of file request.cpp.
References QMap::constEnd(), QMultiMap::constFind(), QMap::const_iterator::key(), QList::prepend(), and queryParameters().
| QVariantMap Request::queryParametersVariant | ( | ) | const |
Returns a QVariantMap of query string parameters, this method is expensive as it creates the map each time it's called, cache it's result instead of calling multiple times
Definition at line 245 of file request.cpp.
References queryParameters().
|
inline |
Short for queryParameters()
Referenced by mangleParams().
|
inline |
Convenience method for geting all query values passing a key
Definition at line 545 of file request.h.
References queryParameters().
|
inline |
referer Shortcut for header("Referer")
|
noexcept |
Returns the value of the REMOTE_USER environment variable.
|
noexcept |
Returns true or false to indicate that a connection is secure (https), The reliability of it may depend on your server configuration, Cutelyst relies on the Engine to set this information which is used to build up uri().scheme(). The Engine itself might not be aware of a front HTTP server with https enabled.
| void Request::setArguments | ( | const QStringList & | arguments | ) |
Defines the arguments of the request Useful for custom dispatchers and/or actions
Definition at line 155 of file request.cpp.
References arguments().
Referenced by Cutelyst::ActionChain::doExecute(), Cutelyst::DispatchTypePath::match(), and Cutelyst::DispatchTypeChained::match().
| void Request::setCaptures | ( | const QStringList & | captures | ) |
Defines the arguments of the request Useful for custom dispatchers and/or actions
Definition at line 167 of file request.cpp.
References captures().
Referenced by Cutelyst::DispatchTypeChained::match().
| void Request::setMatch | ( | const QString & | match | ) |
Defines the matching part of the request Useful for custom dispatchers
Definition at line 143 of file request.cpp.
References match().
Referenced by Cutelyst::DispatchTypeChained::match(), and Cutelyst::DispatchTypePath::match().
Returns the first Upload object for the given field, if no upload matches the field name this function returns 0.
Definition at line 563 of file request.h.
References uploadsMap().
Returns a vector containing uploads as provided by a multipart/form-data content type
Definition at line 374 of file request.cpp.
Returns all (if any) Upload objects for the given field.
Definition at line 392 of file request.cpp.
References QVector::push_back(), and uploadsMap().
| QMultiMap< QString, Cutelyst::Upload * > Request::uploadsMap | ( | ) | const |
Returns a map containing uploads, where their key is the field name.
Definition at line 383 of file request.cpp.
| QUrl Cutelyst::Request::uri | ( | ) | const |
Returns the uri as close as possible to what the user has in his browser url.
Referenced by uriWith().
| QUrl Request::uriWith | ( | const ParamsMultiMap & | args, |
| bool | append = false |
||
| ) | const |
Returns a rewritten URI object for the current request. Key/value pairs passed in will override existing parameters. You can remove an existing parameter by passing in an undef value. Unmodified pairs will be preserved.
You may also pass an optional second parameter that puts uriWith() into append mode:
See mangleParams() for an explanation of this behavior.
Definition at line 419 of file request.cpp.
References QUrlQuery::addQueryItem(), args(), QMap::constBegin(), QMap::constEnd(), mangleParams(), QUrl::setQuery(), and uri().
|
inline |
Returns the user agent (browser) version string.
|
signal |
|
noexcept |
Returns true if the request's X-Requested-With header field is "XMLHttpRequest", indicating that the request was issued by a client library such as jQuery.
Definition at line 362 of file request.cpp.
1.8.14