RestLink 2.2.0
Powerfull Rest Client for Qt
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
RestLink::Response Class Referenceabstract

Represents a response to an API request in the RestLink framework. More...

#include <response.h>

Inherits RestLink::ResponseBase.

Inherited by RestLink::NetworkResponse, and RestLink::ServerResponse.

Public Slots

virtual void ignoreSslErrors ()
 
virtual void abort ()=0
 

Signals

void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 
void uploadProgress (qint64 bytesSent, qint64 bytesTotal)
 
void networkErrorOccured (int error)
 
void finished ()
 
void sslErrorsOccured (const QList< QSslError > &errors)
 

Public Member Functions

virtual ~Response ()
 Destructor for Response.
 
QString endpoint () const
 Retrieves the API endpoint associated with this response.
 
Request request () const
 Retrieves the API request associated with this response.
 
virtual AbstractRequestHandler::Method method () const =0
 
Apiapi () const
 Retrieves the API instance associated with this response.
 
QUrl url () const
 Retrieves the URL associated with this response.
 
virtual QNetworkRequest networkRequest () const =0
 Retrieves the network request used in this response.
 
bool isRunning () const
 Checks if the request is currently running.
 
virtual bool isFinished () const =0
 Checks if the request has finished processing.
 
bool isSuccess () const
 Checks if the request was successful.
 
bool isHttpStatusSuccess () const
 Checks if the HTTP status code indicates success.
 
bool hasHttpStatusCode () const
 Checks if the HTTP status code is valid.
 
virtual int httpStatusCode () const =0
 
virtual QString httpReasonPhrase () const
 
virtual bool hasHeader (const QByteArray &name) const
 Checks if the response contains a specific header.
 
virtual Q_INVOKABLE QByteArray header (const QByteArray &name) const =0
 Retrieves the value of a specific header.
 
virtual QByteArrayList headerList () const =0
 
bool hasNetworkError () const
 
virtual int networkError () const
 Retrieves the network error code.
 
virtual QString networkErrorString () const
 Retrieves a string description of the network error.
 
virtual QNetworkReply * networkReply () const =0
 

Protected Member Functions

 Response (ResponsePrivate *d, QObject *parent)
 
void setRequest (const Request &request)
 
QByteArray body ()
 

Protected Attributes

QScopedPointer< ResponsePrivate > d_ptr
 

Properties

QString endpoint
 
int method
 Retrieves the HTTP method type for this response.
 
QUrl url
 
bool running
 
bool finished
 
bool success
 
bool hasHttpStatusCode
 
int httpStatusCode
 Retrieves the HTTP status code of the response.
 
QString httpReasonPhrase
 Retrieves the HTTP reason phrase of the response.
 
QByteArrayList headerList
 Retrieves a list of all headers in the response.
 
bool hasNetworkError
 Checks if a network error occurred during the request.
 
int networkError
 
QString networkErrorString
 
QByteArray body
 

Detailed Description

Represents a response to an API request in the RestLink framework.

The Response class encapsulates the response from an API request, providing methods for accessing various aspects of the response such as status, headers, body, and progress. It also provides signals for progress updates, completion, and error handling.

The Response object is associated with a specific API request and provides functionality to handle download/upload progress, SSL errors, network errors, and HTTP status codes. It also supports reading the response body as JSON or raw data and provides the option to abort or ignore specific errors during the process.

Constructor & Destructor Documentation

◆ ~Response()

RestLink::Response::~Response ( )
virtual

Destructor for Response.

Cleans up resources held by the Response object.

◆ Response()

RestLink::Response::Response ( ResponsePrivate *  d,
QObject *  parent 
)
protected

Member Function Documentation

◆ endpoint()

QString RestLink::Response::endpoint ( ) const

Retrieves the API endpoint associated with this response.

Returns
The endpoint as a QString.

◆ request()

Request RestLink::Response::request ( ) const

Retrieves the API request associated with this response.

Returns
The Request object.

◆ method()

virtual AbstractRequestHandler::Method RestLink::Response::method ( ) const
pure virtual

◆ api()

Api * RestLink::Response::api ( ) const

Retrieves the API instance associated with this response.

Returns
A pointer to the Api object.

◆ url()

QUrl RestLink::Response::url ( ) const

Retrieves the URL associated with this response.

Returns
The URL as a QUrl object.

◆ networkRequest()

RestLink::Response::networkRequest ( ) const
pure virtual

Retrieves the network request used in this response.

Returns
The QNetworkRequest object.

Implemented in RestLink::NetworkResponse, and RestLink::ServerResponse.

◆ isRunning()

RestLink::Response::isRunning ( ) const
inline

Checks if the request is currently running.

Returns
true if the request is running, otherwise false.

◆ isFinished()

RestLink::Response::isFinished ( ) const
pure virtual

Checks if the request has finished processing.

Returns
true if the request is finished, otherwise false.

Implemented in RestLink::NetworkResponse, and RestLink::ServerResponse.

◆ isSuccess()

RestLink::Response::isSuccess ( ) const
inline

Checks if the request was successful.

Returns
true if the request was successful, otherwise false.

◆ isHttpStatusSuccess()

bool RestLink::Response::isHttpStatusSuccess ( ) const

Checks if the HTTP status code indicates success.

Returns
true if the HTTP status code indicates success, otherwise false.

◆ hasHttpStatusCode()

bool RestLink::Response::hasHttpStatusCode ( ) const

Checks if the HTTP status code is valid.

Returns
true if the HTTP status code is valid, otherwise false.

◆ httpStatusCode()

virtual int RestLink::Response::httpStatusCode ( ) const
pure virtual

◆ httpReasonPhrase()

QString RestLink::Response::httpReasonPhrase ( ) const
virtual

Reimplemented in RestLink::NetworkResponse.

◆ hasHeader()

bool RestLink::Response::hasHeader ( const QByteArray &  name) const
virtual

Checks if the response contains a specific header.

Parameters
nameThe name of the header to check.
Returns
true if the header is present, otherwise false.

Reimplemented in RestLink::NetworkResponse, and RestLink::ServerResponse.

◆ header()

RestLink::Response::header ( const QByteArray &  name) const
pure virtual

Retrieves the value of a specific header.

Parameters
headerThe name of the header to retrieve.
Returns
The header value as a QByteArray.

Implemented in RestLink::NetworkResponse, and RestLink::ServerResponse.

◆ headerList()

virtual QByteArrayList RestLink::Response::headerList ( ) const
pure virtual

◆ hasNetworkError()

bool RestLink::Response::hasNetworkError ( ) const
inline

◆ networkError()

int RestLink::Response::networkError ( ) const
virtual

Retrieves the network error code.

Returns
The network error code.

Reimplemented in RestLink::NetworkResponse.

◆ networkErrorString()

QString RestLink::Response::networkErrorString ( ) const
virtual

Retrieves a string description of the network error.

Returns
The network error description as a QString.

Reimplemented in RestLink::NetworkResponse.

◆ networkReply()

virtual QNetworkReply * RestLink::Response::networkReply ( ) const
pure virtual

◆ setRequest()

void RestLink::Response::setRequest ( const Request request)
protected

◆ body()

QByteArray RestLink::Response::body ( )
protected

◆ ignoreSslErrors

void RestLink::Response::ignoreSslErrors ( )
virtualslot

◆ abort

virtual void RestLink::Response::abort ( )
pure virtualslot

◆ downloadProgress

void RestLink::Response::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
)
signal

◆ uploadProgress

void RestLink::Response::uploadProgress ( qint64  bytesSent,
qint64  bytesTotal 
)
signal

◆ networkErrorOccured

void RestLink::Response::networkErrorOccured ( int  error)
signal

◆ finished

void RestLink::Response::finished ( )
signal

◆ sslErrorsOccured

void RestLink::Response::sslErrorsOccured ( const QList< QSslError > &  errors)
signal

Member Data Documentation

◆ d_ptr

QScopedPointer<ResponsePrivate> RestLink::Response::d_ptr
protected

Property Documentation

◆ endpoint

QString RestLink::Response::endpoint
read

◆ method

RestLink::Response::method
read

Retrieves the HTTP method type for this response.

Returns
The HTTP mthod as an Api::Method.

◆ url

QUrl RestLink::Response::url
read

◆ running

bool RestLink::Response::running
read

◆ finished

bool RestLink::Response::finished
read

◆ success

bool RestLink::Response::success
read

◆ hasHttpStatusCode

bool RestLink::Response::hasHttpStatusCode
read

◆ httpStatusCode

RestLink::Response::httpStatusCode
read

Retrieves the HTTP status code of the response.

Returns
The HTTP status code.

◆ httpReasonPhrase

RestLink::Response::httpReasonPhrase
read

Retrieves the HTTP reason phrase of the response.

Returns
The HTTP reason phrase as a QString.

◆ headerList

RestLink::Response::headerList
read

Retrieves a list of all headers in the response.

Returns
A QByteArrayList containing the header names.

◆ hasNetworkError

RestLink::Response::hasNetworkError
read

Checks if a network error occurred during the request.

Returns
true if a network error occurred, otherwise false.

◆ networkError

int RestLink::Response::networkError
read

◆ networkErrorString

QString RestLink::Response::networkErrorString
read

◆ body

QByteArray RestLink::Response::body
read