|
RestLink 2.2.0
Powerfull Rest Client for Qt
|
A class for storing and managing HTTP request information. More...
#include <request.h>
Inherits RestLink::RequestInterface.
Inherited by RestLink::ServerRequest.
Public Types | |
| enum | Attribute { CacheLoadControlAttribute , CacheSaveControlAttribute , CompressionAllowedAttribute } |
| Defines configurable attributes that influence request behavior. More... | |
| enum | UrlType { PublicUrl , SecretUrl } |
| Defines the type of URL associated with the request. More... | |
Public Member Functions | |
| Request () | |
| Default constructor for Request. | |
| Request (const char *endpoint) | |
| Constructs an Request object with a specified endpoint. | |
| Request (const QString &endpoint) | |
| Constructs an Request object with a specified endpoint. | |
| Request (const QUrl &url) | |
| Construct a Request object with a specified URL. | |
| Request (const RequestProcessing &processing) | |
| Request (const Request &other) | |
| Copy constructor for Request. | |
| Request (Request &&other) | |
| Move constructor for Request. | |
| virtual | ~Request () |
| Destructor for Request. | |
| Request & | operator= (const Request &other) |
| Copy assignment operator for Request. | |
| Request & | operator= (const Request &&other) |
| Move assignment operator for Request. | |
| QString | endpoint () const |
| Retrieves the API endpoint associated with this request. | |
| void | setEndpoint (const QString &endpoint) |
| Set the API endpoint associated with this request. | |
| QUrl | baseUrl () const |
| Retrieves the API base url associated with this request. | |
| void | setBaseUrl (const QUrl &url) |
| Set the API base url associated with this request. | |
| QUrl | url (UrlType type=SecretUrl) const |
| Construct the full URL for the request. | |
| QString | urlPath () const |
| Constructs the URL path for the request based on its parameters and endpoint. | |
| QHttpHeaders | httpHeaders () const |
| Return the corresponding http headers for the request. | |
| QVariant | attribute (Attribute attribute) const |
| Returns the attribute associated with the code code. | |
| QVariant | attribute (Attribute attribute, const QVariant &defaultValue) const |
| Returns the attribute associated with the code code. Return defaultValue if the attribute has not been set. | |
| void | setAttribute (Attribute attribute, const QVariant &value) |
| Set attribute value to the provided one. | |
| RequestProcessing | processing () const |
| void | setProcessing (RequestProcessing processing) |
| AbstractController * | controller () const |
| Get the controller associated with the request. | |
| void | setController (AbstractController *controller) |
| Associate a controller to the request. | |
| Api * | api () const |
| return the Api associated to this request | |
| void | setApi (Api *api) |
| Associate an Api to this request. | |
| QJsonObject | toJsonObject () const |
| void | swap (Request &other) |
| Swaps the contents of this Request with another. | |
Public Member Functions inherited from RestLink::RequestInterface | |
| bool | hasPathParameter (const QString &name) const |
| Checks if a path parameter exists in the request. | |
| PathParameter | pathParameter (const QString &name) const |
| Retrieves a specific path parameter. | |
| QVariant | pathParameterValue (const QString &name) const |
| Retrieves the value of a path parameter. | |
| QStringList | pathParameterNames () const |
| Retrieves the names of all path parameters. | |
| void | setPathParameter (const QString &name, const QVariant &value) |
| Sets the value of a path parameter. | |
| void | setPathParameter (const PathParameter ¶meter) |
Sets a path parameter using a PathParameter object. | |
| void | unsetPathParameter (const QString &name) |
| Unsets (removes) a path parameter from the request. | |
| QList< PathParameter > | pathParameters () const |
| Retrieves all path parameters. | |
| void | setPathParameters (const QList< PathParameter > ¶meters) |
| Sets all path parameters. | |
| bool | hasQueryParameter (const QString &name) const |
| Checks if a query parameter exists in the request. | |
| QueryParameter | queryParameter (const QString &name) const |
| Retrieves a specific query parameter. | |
| QList< QVariant > | queryParameterValues (const QString &name) const |
| Retrieves the values of a query parameter. | |
| QStringList | queryParameterNames () const |
| Retrieves the names of all query parameters. | |
| void | addQueryParameter (const QString &name, const QVariant &value) |
| Add the value of a query parameter. | |
| void | addQueryParameter (const QueryParameter ¶m) |
Add query parameter using a QueryParameter object. | |
| void | removeQueryParameter (const QString &name) |
| Removes a query parameter from the request. | |
| void | removeQueryParameter (const QString &name, const QVariant &value) |
| Removes a query parameter from the request. | |
| QList< QueryParameter > | queryParameters () const |
| Retrieves all query parameters. | |
| void | setQueryParameters (const QList< QueryParameter > ¶meters) |
| Sets all query parameters. | |
| bool | hasHeader (const QString &name) const |
| Checks if a header exists in the request. | |
| Header | header (const QString &name) const |
| Retrieves a specific header. | |
| QList< QVariant > | headerValues (const QString &name) const |
| Retrieves the values of a header. | |
| QStringList | headerNames () const |
| Retrieves the names of all headers. | |
| void | setHeader (const QString &name, const QVariant &value) |
| Sets the value of a header. | |
| void | setHeader (const Header &header) |
Sets a header using a Header object. | |
| void | unsetHeader (const QString &name) |
| Unsets (removes) a header from the request. | |
| QList< Header > | headers () const |
| Retrieves all headers. | |
| void | setHeaders (const QList< Header > &headers) |
| Sets all headers. | |
Static Public Member Functions | |
| static Request | fromJsonbject (const QJsonObject &object) |
| static Request | merge (const Request &r1, const Request &r2) |
| Merges two Request objects into a single request. | |
Protected Member Functions | |
| Request (RequestPrivate *d) | |
Protected Attributes | |
| QSharedDataPointer< RequestPrivate > | d_ptr |
A class for storing and managing HTTP request information.
The Request class encapsulates the essential details of an HTTP request, such as the endpoint, HTTP method, headers, query parameters, and more. It provides a convenient way to define and organize API requests before execution using RestLink.
Defines configurable attributes that influence request behavior.
These attributes control how the request interacts with caching and compression mechanisms.
Defines the type of URL associated with the request.
These types help differentiate between publicly accessible URLs and those containing sensitive data.
| Enumerator | |
|---|---|
| PublicUrl | A URL intended for general or non-sensitive access. |
| SecretUrl | A URL that may contain confidential or authentication-related information. |
| RestLink::Request::Request | ( | ) |
| RestLink::Request::Request | ( | const char * | endpoint | ) |
Constructs an Request object with a specified endpoint.
This constructor initializes the Request object with the given API endpoint. The endpoint will be used for making requests. Other parameters (such as headers or query parameters) will be empty by default.
| endpoint | The API endpoint as a C-style string (const char*). |
| RestLink::Request::Request | ( | const QString & | endpoint | ) |
Constructs an Request object with a specified endpoint.
This constructor initializes the Request object with the given API endpoint. The endpoint will be used for making requests. Other parameters (such as headers or query parameters) will be empty by default.
| endpoint | The API endpoint as a QString. |
| RestLink::Request::Request | ( | const QUrl & | url | ) |
Construct a Request object with a specified URL.
This constructor initialize the Request object with the given URL. The url must be include the scheme i.e starting with http/https.
| url | The url as a QUrl. |
| RestLink::Request::Request | ( | const RequestProcessing & | processing | ) |
| RestLink::Request::Request | ( | const Request & | other | ) |
| RestLink::Request::Request | ( | Request && | other | ) |
|
virtual |
|
protected |
Move assignment operator for Request.
Transfers ownership of the data from another Request object to this one. The existing data in this object is replaced, and the source object is left in a valid but unspecified state.
| other | The Request object to move from. |
| QString RestLink::Request::endpoint | ( | ) | const |
Retrieves the API endpoint associated with this request.
| void RestLink::Request::setEndpoint | ( | const QString & | endpoint | ) |
Set the API endpoint associated with this request.
| endpoint | The endpoint as a QString. |
| QUrl RestLink::Request::baseUrl | ( | ) | const |
Retrieves the API base url associated with this request.
| void RestLink::Request::setBaseUrl | ( | const QUrl & | url | ) |
Set the API base url associated with this request.
| url | The new base url |
Construct the full URL for the request.
| type | The url type to return. |
| QString RestLink::Request::urlPath | ( | ) | const |
Constructs the URL path for the request based on its parameters and endpoint.
| QHttpHeaders RestLink::Request::httpHeaders | ( | ) | const |
Return the corresponding http headers for the request.
| QVariant RestLink::Request::attribute | ( | Attribute | attribute | ) | const |
Returns the attribute associated with the code code.
| attribute | The attribute for which we want value. |
| QVariant RestLink::Request::attribute | ( | Attribute | attribute, |
| const QVariant & | defaultValue | ||
| ) | const |
Returns the attribute associated with the code code. Return defaultValue if the attribute has not been set.
| attribute | The attribute for which we want value. |
| void RestLink::Request::setAttribute | ( | Attribute | attribute, |
| const QVariant & | value | ||
| ) |
Set attribute value to the provided one.
| attribute | The attribute for which value must ve set. |
| value | The value of the attribute to set. |
| RequestProcessing RestLink::Request::processing | ( | ) | const |
| void RestLink::Request::setProcessing | ( | RequestProcessing | processing | ) |
| AbstractController * RestLink::Request::controller | ( | ) | const |
Get the controller associated with the request.
| void RestLink::Request::setController | ( | AbstractController * | controller | ) |
Associate a controller to the request.
| controller | The controller to set. |
| void RestLink::Request::setApi | ( | Api * | api | ) |
| QJsonObject RestLink::Request::toJsonObject | ( | ) | const |
|
static |
| void RestLink::Request::swap | ( | Request & | other | ) |
|
protected |