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

A request. More...

#include <Cutelyst/Request>

Inheritance diagram for Cutelyst::Request:

Classes

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.
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)
virtual ~Request ()
QHostAddress address () const noexcept
QString addressString () const
QStringList args () const noexcept
QStringList arguments () const noexcept
QString base () const
QIODevicebody () const noexcept
QCborValue bodyCbor () 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
QByteArray contentEncoding () const noexcept
QByteArray contentType () const
QByteArray cookie (QByteArrayView name) const
QMultiMap< QByteArrayView, Cookiecookies () const
QByteArrayList cookies (QByteArrayView name) const
Engineengine () const noexcept
QByteArray header (QByteArrayView key) const noexcept
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
QByteArray method () const noexcept
QString path () const noexcept
quint16 port () const noexcept
QByteArray 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
QByteArray referer () const noexcept
QString remoteUser () const noexcept
bool secure () const noexcept
void setArguments (const QStringList &arguments)
void setCaptures (const QStringList &captures)
void setMatch (const QString &match)
Uploadupload (QStringView name) const
QVector< Upload * > uploads () const
Uploads uploads (QStringView name) const
QMultiMap< QStringView, Upload * > uploadsMap () const
QUrl uri () const
QUrl uriWith (const ParamsMultiMap &args, bool append=false) const
QByteArray userAgent () const noexcept
bool xhr () const noexcept
Public Member Functions inherited from QObject
 QObject (QObject *parent)
QBindable< QStringbindableObjectName ()
bool blockSignals (bool block)
const QObjectListchildren () 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 dumpObjectTree () const const
QList< QByteArraydynamicPropertyNames () const const
virtual bool event (QEvent *e)
virtual bool eventFilter (QObject *watched, QEvent *event)
findChild (QAnyStringView name, Qt::FindChildOptions options) const const
findChild (Qt::FindChildOptions options) const const
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
QList< T > findChildren (QAnyStringView name, Qt::FindChildOptions options) const const
QList< T > findChildren (Qt::FindChildOptions options) const const
bool inherits (const char *className) const const
void installEventFilter (QObject *filterObj)
bool isQmlExposed () const const
bool isQuickItemType () const const
bool isWidgetType () const const
bool isWindowType () const const
void killTimer (int id)
void killTimer (Qt::TimerId id)
virtual const QMetaObjectmetaObject () const const
bool moveToThread (QThread *targetThread)
QString objectName () const const
void objectNameChanged (const QString &objectName)
QObjectparent () const const
QVariant property (const char *name) const const
 Q_CLASSINFO (Name, Value)
 Q_EMIT Q_EMIT
 Q_ENUM (...)
 Q_ENUM_NS (...)
 Q_ENUMS (...)
 Q_FLAG (...)
 Q_FLAG_NS (...)
 Q_FLAGS (...)
 Q_GADGET Q_GADGET
 Q_GADGET_EXPORT (EXPORT_MACRO)
 Q_INTERFACES (...)
 Q_INVOKABLE Q_INVOKABLE
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 Q_NAMESPACE Q_NAMESPACE
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 Q_OBJECT Q_OBJECT
 Q_PROPERTY (...)
 Q_REVISION Q_REVISION
 Q_SET_OBJECT_NAME (Object)
 Q_SIGNAL Q_SIGNAL
 Q_SIGNALS Q_SIGNALS
 Q_SLOT Q_SLOT
 Q_SLOTS Q_SLOTS
qobject_cast (const QObject *object)
qobject_cast (QObject *object)
 QT_NO_CONTEXTLESS_CONNECT QT_NO_CONTEXTLESS_CONNECT
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
void removeEventFilter (QObject *obj)
void setObjectName (const QString &name)
void setObjectName (QAnyStringView name)
void setParent (QObject *parent)
bool setProperty (const char *name, const QVariant &value)
bool setProperty (const char *name, QVariant &&value)
bool signalsBlocked () const const
int startTimer (int interval, Qt::TimerType timerType)
int startTimer (std::chrono::nanoseconds interval, Qt::TimerType timerType)
QThreadthread () const const

Properties

QStringList args
QStringList arguments
QString base
QVariant bodyData
Cutelyst::ParamsMultiMap bodyParams
QByteArray contentEncoding
QByteArray contentType
QString hostname
QString match
QByteArray method
QString path
quint16 port
QByteArray protocol
Cutelyst::ParamsMultiMap queryParams
QByteArray referer
QString remoteUser
bool secure
QUrl uri
QByteArray userAgent
Properties inherited from QObject
 objectName

Friends

class Application
class Context
class Dispatcher
class DispatchType

Additional Inherited Members

Public Types inherited from QObject
enum  TimerId
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 *context, Functor functor, 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)
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, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
QString tr (const char *sourceText, const char *disambiguation, int n)
Public Attributes inherited from QObject
 Invalid
typedef QObjectList
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
QObjectsender () const const
int senderSignalIndex () const const
virtual void timerEvent (QTimerEvent *event)

Detailed Description

A request contains the data that should be handled by your application for the client.

Definition at line 41 of file request.h.

Constructor & Destructor Documentation

◆ ~Request()

Request::~Request ( )
virtual

Destroys the Request object.

Definition at line 27 of file request.cpp.

◆ Request()

Member Function Documentation

◆ address()

QHostAddress Request::address ( ) const
nodiscardnoexcept

Returns the address of the client.

Definition at line 34 of file request.cpp.

References Request().

◆ addressString()

QString Request::addressString ( ) const
nodiscard

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 40 of file request.cpp.

References Request(), and QHostAddress::toString().

◆ args()

QStringList Cutelyst::Request::args ( ) const
inlinenodiscardnoexcept

Shortcut for arguments().

Definition at line 556 of file request.h.

References Request().

◆ arguments()

QStringList Request::arguments ( ) const
nodiscardnoexcept

Returns a list of string containing the arguments. For example, if your action was

class foo : public Cutelyst::Controller
{
public:
C_ATTR(bar, :Local)
void bar(Context *c);
};
Cutelyst Controller base class.
Definition controller.h:56
#define C_ATTR(X, Y)
Definition controller.h:41

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.

Definition at line 150 of file request.cpp.

References Request().

◆ base()

QString Request::base ( ) const
nodiscard

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'.

Definition at line 112 of file request.cpp.

References Request(), QString::fromLatin1(), and QHostInfo::localHostName().

◆ body()

QIODevice * Request::body ( ) const
nodiscardnoexcept

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 180 of file request.cpp.

References Request().

Referenced by Cutelyst::UA::forwardRequest().

◆ bodyCbor()

QCborValue Request::bodyCbor ( ) const
nodiscard

When request Content-Type is 'application/cbor' this will contain the parsed CBOR value.

Definition at line 195 of file request.cpp.

References bodyData(), and QVariant::value().

◆ bodyData()

QVariant Request::bodyData ( ) const
nodiscard

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.

Definition at line 186 of file request.cpp.

References Request().

Referenced by bodyCbor(), bodyJsonArray(), bodyJsonDocument(), and bodyJsonObject().

◆ bodyJsonArray()

QJsonArray Request::bodyJsonArray ( ) const
nodiscard

When request Content-Type is 'application/json' this will contain the parsed JSON representation array.

Definition at line 210 of file request.cpp.

References QJsonDocument::array(), bodyData(), and QVariant::toJsonDocument().

◆ bodyJsonDocument()

QJsonDocument Request::bodyJsonDocument ( ) const
nodiscard

When request Content-Type is 'application/json' this will contain the parsed JSON representation document.

Definition at line 200 of file request.cpp.

References bodyData(), and QVariant::toJsonDocument().

◆ bodyJsonObject()

QJsonObject Request::bodyJsonObject ( ) const
nodiscard

When request Content-Type is 'application/json' this will contain the parsed JSON representation object.

Definition at line 205 of file request.cpp.

References bodyData(), QJsonDocument::object(), and QVariant::toJsonDocument().

◆ bodyParam()

QString Cutelyst::Request::bodyParam ( const QString & key,
const QString & defaultValue = {} ) const
inlinenodiscard

Convenience method for geting a single body value passing a key and an optional default value

Definition at line 571 of file request.h.

References bodyParam(), and bodyParameters().

Referenced by bodyParam().

◆ bodyParameter()

QString Cutelyst::Request::bodyParameter ( const QString & key,
const QString & defaultValue = {} ) const
inlinenodiscard

Convenience method for geting a single body value passing a key and an optional default value

Definition at line 561 of file request.h.

References bodyParameter(), and bodyParameters().

Referenced by bodyParameter().

◆ bodyParameters() [1/2]

ParamsMultiMap Request::bodyParameters ( ) const
nodiscard

Returns a Map of body (POST/PUT) parameters when content type is application/x-www-form-urlencoded

Definition at line 220 of file request.cpp.

References Request().

Referenced by bodyParam(), bodyParameter(), bodyParameters(), bodyParametersVariant(), bodyParams(), bodyParams(), and Cutelyst::Validator::validate().

◆ bodyParameters() [2/2]

QStringList Request::bodyParameters ( const QString & key) const
nodiscard

Convenience method for geting all body values passing a key

Note
Unlike QMap::values() this return values in insertion order.

Definition at line 229 of file request.cpp.

References bodyParameters(), QMultiMap::constEnd(), QMultiMap::constFind(), and QList::prepend().

◆ bodyParametersVariant()

QVariantMap Request::bodyParametersVariant ( ) const
nodiscard

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 215 of file request.cpp.

References bodyParameters().

◆ bodyParams() [1/2]

ParamsMultiMap Cutelyst::Request::bodyParams ( ) const
inlinenodiscard

Short for bodyParameters()

Definition at line 566 of file request.h.

References bodyParameters().

◆ bodyParams() [2/2]

QStringList Cutelyst::Request::bodyParams ( const QString & key) const
inlinenodiscard

Convenience method for geting all body values passing a key

Note
Unlike QMap::values() this return values in insertion order.

Definition at line 576 of file request.h.

References bodyParameters().

◆ captures()

QStringList Request::captures ( ) const
nodiscardnoexcept

Returns captures.

Definition at line 162 of file request.cpp.

References Request().

Referenced by Cutelyst::ActionChain::doExecute(), and setCaptures().

◆ contentEncoding()

QByteArray Cutelyst::Request::contentEncoding ( ) const
inlinenodiscardnoexcept

Returns the Content-Encoding header

Definition at line 601 of file request.h.

References headers().

◆ contentType()

QByteArray Cutelyst::Request::contentType ( ) const
inlinenodiscard

Returns the Content-Type header

Definition at line 606 of file request.h.

References headers().

◆ cookie()

QByteArray Request::cookie ( QByteArrayView name) const
nodiscard

Returns the first cookie value with the given name

Definition at line 278 of file request.cpp.

References Request().

◆ cookies() [1/2]

QMultiMap< QByteArrayView, Request::Cookie > Request::cookies ( ) const
nodiscard

Returns all the cookies from the request

Definition at line 304 of file request.cpp.

References Request().

◆ cookies() [2/2]

QByteArrayList Request::cookies ( QByteArrayView name) const
nodiscard

Returns a list of cookies that match with the given name

Note
this return values in insertion order.

Definition at line 288 of file request.cpp.

References Request(), and QList::prepend().

◆ engine()

Engine * Request::engine ( ) const
nodiscardnoexcept

Returns the current Engine processing the requests.

Definition at line 439 of file request.cpp.

References Request().

◆ header()

QByteArray Cutelyst::Request::header ( QByteArrayView key) const
inlinenodiscardnoexcept

Short for headers().header(key);

Definition at line 611 of file request.h.

References header(), and headers().

Referenced by header().

◆ headers()

Headers Request::headers ( ) const
nodiscardnoexcept

Returns the HTTP request headers

Definition at line 313 of file request.cpp.

References Request().

Referenced by contentEncoding(), contentType(), Cutelyst::UA::forwardRequest(), header(), referer(), Cutelyst::ViewJson::render(), and userAgent().

◆ hostname()

QString Request::hostname ( ) const
nodiscard

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.

Definition at line 53 of file request.cpp.

References Request(), QHostInfo::error(), QHostInfo::fromName(), QHostInfo::hostName(), and QHostInfo::NoError.

◆ isDelete()

bool Request::isDelete ( ) const
nodiscardnoexcept

Returns true if the request method is DELETE.

Definition at line 355 of file request.cpp.

References Request().

◆ isGet()

bool Request::isGet ( ) const
nodiscardnoexcept

Returns true if the request method is GET.

Definition at line 331 of file request.cpp.

References Request().

◆ isHead()

bool Request::isHead ( ) const
nodiscardnoexcept

Returns true if the request method is HEAD.

Definition at line 337 of file request.cpp.

References Request().

Referenced by Cutelyst::RenderView::doExecute().

◆ isPatch()

bool Request::isPatch ( ) const
nodiscardnoexcept

Returns true if the request method is PATCH.

Definition at line 349 of file request.cpp.

References Request().

◆ isPost()

bool Request::isPost ( ) const
nodiscardnoexcept

Returns true if the request method is POST.

Definition at line 325 of file request.cpp.

References Request().

◆ isPut()

bool Request::isPut ( ) const
nodiscardnoexcept

Returns true if the request method is PUT.

Definition at line 343 of file request.cpp.

References Request().

◆ mangleParams()

ParamsMultiMap Request::mangleParams ( const ParamsMultiMap & args,
bool append = false ) const
nodiscard

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:

// URI query params foo=1
ParamsMultiMap params = request->mangleParams({ {"foo", "2"} });
// Result is query params of foo=2
QMultiMap< QString, QString > ParamsMultiMap

versus append mode:

// URI query params foo=1
ParamsMultiMap params = request->mangleParams({ {"foo", "2"} }, true);
// Result is query params of foo=1&foo=2

This is the code behind uriWith().

Definition at line 408 of file request.cpp.

References queryParams(), QMultiMap::replace(), and QMultiMap::unite().

Referenced by uriWith().

◆ match()

QString Request::match ( ) const
nodiscardnoexcept

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.

Definition at line 138 of file request.cpp.

References Request().

◆ method()

QByteArray Request::method ( ) const
nodiscardnoexcept

Returns the request method (GET, POST, HEAD, etc).

Definition at line 319 of file request.cpp.

References Request().

◆ path()

QString Request::path ( ) const
nodiscardnoexcept

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'.

Definition at line 132 of file request.cpp.

References Request().

◆ port()

quint16 Request::port ( ) const
nodiscardnoexcept

Returns the originating port of the client

Definition at line 76 of file request.cpp.

References Request().

◆ protocol()

QByteArray Request::protocol ( ) const
nodiscardnoexcept

Returns the protocol (HTTP/1.0 or HTTP/1.1) used for the current request.

Definition at line 361 of file request.cpp.

References Request().

◆ queryKeywords()

QString Request::queryKeywords ( ) const
nodiscard

Contains the keywords portion of a query string, when no '=' signs are present.

http://localhost/path?some+keywords
c->request()->queryKeywords() will contain 'some keywords'

Definition at line 242 of file request.cpp.

References Request().

◆ queryParam()

QString Cutelyst::Request::queryParam ( const QString & key,
const QString & defaultValue = {} ) const
inlinenodiscard

Convenience method for geting a single query value passing a key and an optional default value

Definition at line 591 of file request.h.

References queryParam(), and queryParameters().

Referenced by Cutelyst::StatusMessage::load(), and queryParam().

◆ queryParameter()

QString Cutelyst::Request::queryParameter ( const QString & key,
const QString & defaultValue = {} ) const
inlinenodiscard

Convenience method for geting a single query value passing a key and an optional default value

Definition at line 581 of file request.h.

References queryParameter(), and queryParameters().

Referenced by queryParameter().

◆ queryParameters() [1/2]

ParamsMultiMap Request::queryParameters ( ) const
nodiscard

Returns a QMultiHash containing the query string parameters

Definition at line 256 of file request.cpp.

References Request().

Referenced by queryParam(), queryParameter(), queryParameters(), queryParametersVariant(), queryParams(), queryParams(), and Cutelyst::Validator::validate().

◆ queryParameters() [2/2]

QStringList Request::queryParameters ( const QString & key) const
nodiscard

Convenience method for geting all query values passing a key

Note
Unlike QMap::values() this return values in insertion order.

Definition at line 265 of file request.cpp.

References QMultiMap::constEnd(), QMultiMap::constFind(), QList::prepend(), and queryParameters().

◆ queryParametersVariant()

QVariantMap Request::queryParametersVariant ( ) const
nodiscard

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 251 of file request.cpp.

References queryParameters().

◆ queryParams() [1/2]

ParamsMultiMap Cutelyst::Request::queryParams ( ) const
inlinenodiscard

Short for queryParameters()

Definition at line 586 of file request.h.

References queryParameters().

Referenced by mangleParams().

◆ queryParams() [2/2]

QStringList Cutelyst::Request::queryParams ( const QString & key) const
inlinenodiscard

Convenience method for geting all query values passing a key

Note
Unlike QMap::values() this return values in insertion order.

Definition at line 596 of file request.h.

References queryParameters().

◆ referer()

QByteArray Cutelyst::Request::referer ( ) const
inlinenodiscardnoexcept

referer Shortcut for header("Referer")

Definition at line 621 of file request.h.

References headers().

◆ remoteUser()

QString Request::remoteUser ( ) const
nodiscardnoexcept

Returns the value of the REMOTE_USER environment variable.

Definition at line 373 of file request.cpp.

References Request().

◆ secure()

bool Request::secure ( ) const
nodiscardnoexcept

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.

Definition at line 174 of file request.cpp.

References Request().

◆ setArguments()

void Request::setArguments ( const QStringList & arguments)

Defines the arguments of the request. Useful for custom dispatchers and/or actions.

Definition at line 156 of file request.cpp.

References Request().

Referenced by Cutelyst::ActionChain::doExecute(), Cutelyst::DispatchTypeChained::match(), and Cutelyst::DispatchTypePath::match().

◆ setCaptures()

void Request::setCaptures ( const QStringList & captures)

Defines the captures of the request Useful for custom dispatchers and/or actions

Definition at line 168 of file request.cpp.

References Request(), and captures().

Referenced by Cutelyst::DispatchTypeChained::match().

◆ setMatch()

void Request::setMatch ( const QString & match)

Defines the matching part of the request Useful for custom dispatchers

Definition at line 144 of file request.cpp.

References Request().

Referenced by Cutelyst::DispatchTypeChained::match(), and Cutelyst::DispatchTypePath::match().

◆ upload()

Upload * Cutelyst::Request::upload ( QStringView name) const
inlinenodiscard

Returns the first Upload object for the given field, if no upload matches the field name this function returns 0.

Definition at line 626 of file request.h.

References upload(), and uploadsMap().

Referenced by upload().

◆ uploads() [1/2]

QVector< Upload * > Request::uploads ( ) const
nodiscard

Returns a vector containing uploads as provided by a multipart/form-data content type

Definition at line 379 of file request.cpp.

References Request().

◆ uploads() [2/2]

Uploads Request::uploads ( QStringView name) const
nodiscard

Returns all (if any) Upload objects for the given field.

Definition at line 397 of file request.cpp.

References uploadsMap().

◆ uploadsMap()

QMultiMap< QStringView, Cutelyst::Upload * > Request::uploadsMap ( ) const
nodiscard

Returns a map containing uploads, where their key is the field name.

Definition at line 388 of file request.cpp.

References Request().

Referenced by upload(), and uploads().

◆ uri()

QUrl Request::uri ( ) const
nodiscard

Returns the uri as close as possible to what the user has in his browser url.

Definition at line 82 of file request.cpp.

References Request(), QString::fromLatin1(), QHostInfo::localHostName(), and QUrl::url().

Referenced by uriWith().

◆ uriWith()

QUrl Request::uriWith ( const ParamsMultiMap & args,
bool append = false ) const
nodiscard

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:

req->uriWith({ {"key", "value"} }, true);

See mangleParams() for an explanation of this behavior.

Definition at line 424 of file request.cpp.

References QUrlQuery::addQueryItem(), QMultiMap::constBegin(), QMultiMap::constEnd(), mangleParams(), QUrl::setQuery(), and uri().

◆ userAgent()

QByteArray Cutelyst::Request::userAgent ( ) const
inlinenodiscardnoexcept

Returns the user agent (browser) version string.

Definition at line 616 of file request.h.

References headers().

◆ webSocketClosed

void Cutelyst::Request::webSocketClosed ( quint16 closeCode,
const QString & reason )
signal
Note
This signal is NOT emitted when explicit calling
See also
Response::webSocketClose(). If you need to track when the connection was closed, the proper way is to rely on Context::destroyed() signal.

References Request(), and webSocketClosed().

Referenced by webSocketClosed().

◆ xhr()

bool Request::xhr ( ) const
nodiscardnoexcept

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 367 of file request.cpp.

References Request().

◆ Application

friend class Application
friend

Definition at line 549 of file request.h.

◆ Context

friend class Context
friend

Definition at line 552 of file request.h.

◆ Dispatcher

friend class Dispatcher
friend

Definition at line 550 of file request.h.

◆ DispatchType

friend class DispatchType
friend

Definition at line 551 of file request.h.

Property Documentation

◆ args

QStringList Cutelyst::Request::args
read

Definition at line 51 of file request.h.

◆ arguments

QStringList Cutelyst::Request::arguments
read

Definition at line 50 of file request.h.

◆ base

QString Cutelyst::Request::base
read

Definition at line 47 of file request.h.

◆ bodyData

QVariant Cutelyst::Request::bodyData
read

Definition at line 53 of file request.h.

◆ bodyParams

Cutelyst::ParamsMultiMap Cutelyst::Request::bodyParams
read

Definition at line 54 of file request.h.

◆ contentEncoding

QByteArray Cutelyst::Request::contentEncoding
read

Definition at line 56 of file request.h.

◆ contentType

QByteArray Cutelyst::Request::contentType
read

Definition at line 57 of file request.h.

◆ hostname

QString Cutelyst::Request::hostname
read

Definition at line 44 of file request.h.

◆ match

QString Cutelyst::Request::match
read

Definition at line 49 of file request.h.

◆ method

QByteArray Cutelyst::Request::method
read

Definition at line 58 of file request.h.

◆ path

QString Cutelyst::Request::path
read

Definition at line 48 of file request.h.

◆ port

quint16 Cutelyst::Request::port
read

Definition at line 45 of file request.h.

◆ protocol

QByteArray Cutelyst::Request::protocol
read

Definition at line 59 of file request.h.

◆ queryParams

Cutelyst::ParamsMultiMap Cutelyst::Request::queryParams
read

Definition at line 55 of file request.h.

◆ referer

QByteArray Cutelyst::Request::referer
read

Definition at line 61 of file request.h.

◆ remoteUser

QString Cutelyst::Request::remoteUser
read

Definition at line 62 of file request.h.

◆ secure

bool Cutelyst::Request::secure
read

Definition at line 52 of file request.h.

◆ uri

QUrl Cutelyst::Request::uri
read

Definition at line 46 of file request.h.

◆ userAgent

QByteArray Cutelyst::Request::userAgent
read

Definition at line 60 of file request.h.