Base class for HTTP operations executed asynchronously on a dedicated thread.
More...
#include <httpoperation.h>
|
|
void | operationComplete () |
| | Emitted when the HTTP operation has completed.
|
| |
|
|
virtual | ~HttpOperation () |
| | Destructor.
|
| |
| QString | url () const |
| | Return the target URL of this operation.
|
| |
| HttpKnownHeaders | headers () const |
| | Return the known HTTP headers set on this operation.
|
| |
| HttpCustomHeaders | customHeaders () const |
| | Return the custom HTTP headers set on this operation.
|
| |
| void | appendHeader (QNetworkRequest::KnownHeaders type, const QByteArray &value) |
| | Append a known HTTP header to the request.
|
| |
| void | appendHeader (const QString &headerName, const QByteArray &value) |
| | Append a custom HTTP header to the request.
|
| |
|
void | abortOperation () |
| | Abort the running HTTP operation.
|
| |
| QList< QNetworkCookie > | requestCookies () const |
| | Return the cookies to be sent with the request.
|
| |
| void | setRequestCookies (const QList< QNetworkCookie > &value) |
| | Set the cookies to be sent with the request.
|
| |
| QList< QNetworkCookie > | responseCookies () const |
| | Return the cookies received in the response.
|
| |
| bool | isVerifyPeer () const |
| | Return whether peer SSL certificate verification is enabled.
|
| |
| void | setVerifyPeer (bool value) |
| | Enable or disable peer SSL certificate verification.
|
| |
| bool | isSelfSignedCertificateErrorIgnored () const |
| | Return whether self-signed certificate errors are being ignored.
|
| |
|
void | ignoreSelfSignedCertificate () |
| | Configure the operation to ignore self-signed certificate errors.
|
| |
| TimeSpan | transferTimeout () const |
| | Return the transfer timeout duration.
|
| |
| void | setTransferTimeout (const TimeSpan &value) |
| | Set the transfer timeout duration.
|
| |
| QNetworkReply::NetworkError | networkError () const |
| | Return the network error from the completed operation.
|
| |
| QString | reasonPhrase () const |
| | Return the HTTP reason phrase from the response.
|
| |
| QByteArray | responseBody () const |
| | Return the response body data.
|
| |
| int | statusCode () const |
| | Return the HTTP status code from the response.
|
| |
| TimeSpan | duration () const |
| | Return the wall-clock duration of the HTTP operation.
|
| |
| QString | getRequestMethodString () const |
| | Return a human-readable string for this operation's request method.
|
| |
| bool | isHttps () const |
| | Return whether this operation uses HTTPS.
|
| |
|
|
void | onReplyFinished () |
| | Handle the network reply finished signal.
|
| |
| void | onSslErrors (const QList< QSslError > &errors) |
| | Handle SSL errors from the network reply.
|
| |
| void | onReplyError (QNetworkReply::NetworkError error) |
| | Handle a network error from the reply.
|
| |
|
| | HttpOperation (const QString &url, RequestMethod method) |
| | Construct an HTTP operation for the given URL and request method.
|
| |
| virtual void | execute ()=0 |
| | Execute the HTTP operation (implemented by subclasses).
|
| |
| virtual void | postReplyHook (QNetworkReply *) |
| | Hook called after the network reply is received.
|
| |
| void | setUrl (const QString &value) |
| | Set the target URL of this operation.
|
| |
| QNetworkAccessManager * | networkAccessManager () |
| | Return the shared network access manager, creating it if necessary.
|
| |
| void | setReply (QNetworkReply *reply) |
| | Store the network reply and connect its signals.
|
| |
| void | appendHeadersToRequest (QNetworkRequest *request) |
| | Append all configured headers to the given network request.
|
| |
| void | configureSsl (QNetworkRequest *request) |
| | Configure SSL settings on the given network request.
|
| |
|
virtual void | threadFinished () override |
| | Called when the operation thread finishes.
|
| |
Base class for HTTP operations executed asynchronously on a dedicated thread.
Definition at line 12 of file httpoperation.h.
◆ RequestMethod
Enumeration of supported HTTP request methods.
| Enumerator |
|---|
| UnknownMethod | Unknown or uninitialized request method.
|
| Get | HTTP GET method.
|
| Put | HTTP PUT method.
|
| Delete | HTTP DELETE method.
|
| Post | HTTP POST method.
|
| Head | HTTP HEAD method.
|
| Patch | HTTP PATCH method.
|
| MultipartUpload | Multipart file upload method.
|
Definition at line 17 of file httpoperation.h.
◆ HttpOperation()
| HttpOperation::HttpOperation |
( |
const QString & |
url, |
|
|
RequestMethod |
method |
|
) |
| |
|
protected |
Construct an HTTP operation for the given URL and request method.
- Parameters
-
| url | The target URL for the operation. |
| method | The HTTP request method to use. |
◆ appendHeader() [1/2]
| void HttpOperation::appendHeader |
( |
const QString & |
headerName, |
|
|
const QByteArray & |
value |
|
) |
| |
|
inline |
Append a custom HTTP header to the request.
- Parameters
-
| headerName | The custom header name. |
| value | The header value. |
Definition at line 58 of file httpoperation.h.
◆ appendHeader() [2/2]
| void HttpOperation::appendHeader |
( |
QNetworkRequest::KnownHeaders |
type, |
|
|
const QByteArray & |
value |
|
) |
| |
|
inline |
Append a known HTTP header to the request.
- Parameters
-
| type | The known header type. |
| value | The header value. |
Definition at line 53 of file httpoperation.h.
◆ appendHeadersToRequest()
| void HttpOperation::appendHeadersToRequest |
( |
QNetworkRequest * |
request | ) |
|
|
protected |
Append all configured headers to the given network request.
- Parameters
-
| request | The network request to modify. |
◆ configureSsl()
| void HttpOperation::configureSsl |
( |
QNetworkRequest * |
request | ) |
|
|
protected |
Configure SSL settings on the given network request.
- Parameters
-
| request | The network request to configure. |
◆ customHeaders()
Return the custom HTTP headers set on this operation.
- Returns
- The custom headers map.
Definition at line 48 of file httpoperation.h.
◆ duration()
| TimeSpan HttpOperation::duration |
( |
| ) |
const |
|
inline |
Return the wall-clock duration of the HTTP operation.
- Returns
- The duration as a TimeSpan.
Definition at line 116 of file httpoperation.h.
◆ execute()
| virtual void HttpOperation::execute |
( |
| ) |
|
|
protectedpure virtual |
◆ getRequestMethodString() [1/2]
| QString HttpOperation::getRequestMethodString |
( |
| ) |
const |
|
inline |
Return a human-readable string for this operation's request method.
- Returns
- The request method string.
Definition at line 120 of file httpoperation.h.
◆ getRequestMethodString() [2/2]
| static QString HttpOperation::getRequestMethodString |
( |
RequestMethod |
method | ) |
|
|
inlinestatic |
Return a human-readable string for the given request method.
- Parameters
-
| method | The request method to convert. |
- Returns
- The request method string.
Definition at line 129 of file httpoperation.h.
◆ headers()
Return the known HTTP headers set on this operation.
- Returns
- The known headers map.
Definition at line 44 of file httpoperation.h.
◆ isHttps()
| bool HttpOperation::isHttps |
( |
| ) |
const |
Return whether this operation uses HTTPS.
- Returns
- True if the URL scheme is HTTPS.
◆ isSelfSignedCertificateErrorIgnored()
| bool HttpOperation::isSelfSignedCertificateErrorIgnored |
( |
| ) |
const |
Return whether self-signed certificate errors are being ignored.
- Returns
- True if self-signed certificate errors are ignored.
◆ isVerifyPeer()
| bool HttpOperation::isVerifyPeer |
( |
| ) |
const |
|
inline |
Return whether peer SSL certificate verification is enabled.
- Returns
- True if peer verification is enabled.
Definition at line 77 of file httpoperation.h.
◆ networkAccessManager()
| QNetworkAccessManager * HttpOperation::networkAccessManager |
( |
| ) |
|
|
protected |
Return the shared network access manager, creating it if necessary.
- Returns
- A pointer to the QNetworkAccessManager.
◆ networkError()
| QNetworkReply::NetworkError HttpOperation::networkError |
( |
| ) |
const |
|
inline |
Return the network error from the completed operation.
- Returns
- The QNetworkReply::NetworkError code.
Definition at line 100 of file httpoperation.h.
◆ onReplyError
| void HttpOperation::onReplyError |
( |
QNetworkReply::NetworkError |
error | ) |
|
|
protectedslot |
Handle a network error from the reply.
- Parameters
-
| error | The network error code. |
◆ onSslErrors
| void HttpOperation::onSslErrors |
( |
const QList< QSslError > & |
errors | ) |
|
|
protectedslot |
Handle SSL errors from the network reply.
- Parameters
-
| errors | The list of SSL errors encountered. |
◆ postReplyHook()
| virtual void HttpOperation::postReplyHook |
( |
QNetworkReply * |
| ) |
|
|
inlineprotectedvirtual |
◆ reasonPhrase()
| QString HttpOperation::reasonPhrase |
( |
| ) |
const |
|
inline |
Return the HTTP reason phrase from the response.
- Returns
- The reason phrase string.
Definition at line 104 of file httpoperation.h.
◆ requestCookies()
| QList< QNetworkCookie > HttpOperation::requestCookies |
( |
| ) |
const |
|
inline |
Return the cookies to be sent with the request.
- Returns
- The list of request cookies.
Definition at line 65 of file httpoperation.h.
◆ responseBody()
| QByteArray HttpOperation::responseBody |
( |
| ) |
const |
|
inline |
Return the response body data.
- Returns
- The response body as a byte array.
Definition at line 108 of file httpoperation.h.
◆ responseCookies()
| QList< QNetworkCookie > HttpOperation::responseCookies |
( |
| ) |
const |
|
inline |
Return the cookies received in the response.
- Returns
- The list of response cookies.
Definition at line 73 of file httpoperation.h.
◆ setReply()
| void HttpOperation::setReply |
( |
QNetworkReply * |
reply | ) |
|
|
protected |
Store the network reply and connect its signals.
- Parameters
-
| reply | The network reply to track. |
◆ setRequestCookies()
| void HttpOperation::setRequestCookies |
( |
const QList< QNetworkCookie > & |
value | ) |
|
|
inline |
Set the cookies to be sent with the request.
- Parameters
-
| value | The list of cookies. |
Definition at line 69 of file httpoperation.h.
◆ setTransferTimeout()
| void HttpOperation::setTransferTimeout |
( |
const TimeSpan & |
value | ) |
|
|
inline |
Set the transfer timeout duration.
- Parameters
-
| value | The timeout as a TimeSpan. |
Definition at line 96 of file httpoperation.h.
◆ setUrl()
| void HttpOperation::setUrl |
( |
const QString & |
value | ) |
|
|
inlineprotected |
Set the target URL of this operation.
- Parameters
-
Definition at line 157 of file httpoperation.h.
◆ setVerifyPeer()
| void HttpOperation::setVerifyPeer |
( |
bool |
value | ) |
|
|
inline |
Enable or disable peer SSL certificate verification.
- Parameters
-
| value | True to verify the peer certificate. |
Definition at line 81 of file httpoperation.h.
◆ statusCode()
| int HttpOperation::statusCode |
( |
| ) |
const |
|
inline |
Return the HTTP status code from the response.
- Returns
- The status code integer.
Definition at line 112 of file httpoperation.h.
◆ transferTimeout()
| TimeSpan HttpOperation::transferTimeout |
( |
| ) |
const |
|
inline |
Return the transfer timeout duration.
- Returns
- The transfer timeout as a TimeSpan.
Definition at line 92 of file httpoperation.h.
◆ url()
| QString HttpOperation::url |
( |
| ) |
const |
|
inline |
Return the target URL of this operation.
- Returns
- The URL string.
Definition at line 40 of file httpoperation.h.
The documentation for this class was generated from the following file: