KanoopProtocolQt 1.2.3
Qt HTTP operations and MQTT client library
Loading...
Searching...
No Matches
HttpGet Class Reference

HTTP GET operation executed asynchronously on a dedicated thread. More...

#include <httpget.h>

+ Inheritance diagram for HttpGet:
+ Collaboration diagram for HttpGet:

Signals

void dataAvailable (const QByteArray &data)
 Emitted when a chunk of data is available during a streaming read.
 
void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 Emitted to report download progress.
 
- Signals inherited from HttpOperation
void operationComplete ()
 Emitted when the HTTP operation has completed.
 

Public Member Functions

 HttpGet (const QString &url)
 Construct an HTTP GET operation for the given URL.
 
void addParameter (const QString &key, const QString &value)
 Add a query parameter to the GET request.
 
bool streamingRead () const
 streamingRead Set to true to return the response piece by piece as available using the dataAvailable() signal
 
void setStreamingRead (bool value)
 Enable or disable streaming read mode.
 
- Public Member Functions inherited from HttpOperation
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.
 

Protected Member Functions

virtual void execute () override
 Execute the HTTP GET request.
 
virtual void preGetHook (QNetworkRequest *)
 Hook called before the GET request is sent.
 
virtual void postGetHook (QNetworkReply *reply)
 Hook called after the GET reply is received.
 
virtual void postReplyHook (QNetworkReply *reply) override
 Hook called after the network reply is processed.
 
- Protected Member Functions inherited from HttpOperation
 HttpOperation (const QString &url, RequestMethod method)
 Construct an HTTP operation for the given URL and request method.
 
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.
 

Additional Inherited Members

- Public Types inherited from HttpOperation
enum  RequestMethod {
  UnknownMethod = 0x0000 , Get = 0x0001 , Put = 0x0002 , Delete = 0x0004 ,
  Post = 0x0008 , Head = 0x0010 , Patch = 0x0040 , MultipartUpload = 0x1000
}
 Enumeration of supported HTTP request methods. More...
 
- Static Public Member Functions inherited from HttpOperation
static QString getRequestMethodString (RequestMethod method)
 Return a human-readable string for the given request method.
 
- Protected Slots inherited from HttpOperation
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.
 

Detailed Description

HTTP GET operation executed asynchronously on a dedicated thread.

Definition at line 7 of file httpget.h.

Constructor & Destructor Documentation

◆ HttpGet()

HttpGet::HttpGet ( const QString &  url)

Construct an HTTP GET operation for the given URL.

Parameters
urlThe target URL.

Member Function Documentation

◆ addParameter()

void HttpGet::addParameter ( const QString &  key,
const QString &  value 
)

Add a query parameter to the GET request.

Parameters
keyThe parameter name.
valueThe parameter value.

◆ dataAvailable

void HttpGet::dataAvailable ( const QByteArray &  data)
signal

Emitted when a chunk of data is available during a streaming read.

Parameters
dataThe received data chunk.

◆ downloadProgress

void HttpGet::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
)
signal

Emitted to report download progress.

Parameters
bytesReceivedThe number of bytes received so far.
bytesTotalThe total number of bytes expected, or -1 if unknown.

◆ execute()

virtual void HttpGet::execute ( )
overrideprotectedvirtual

Execute the HTTP GET request.

Implements HttpOperation.

◆ postGetHook()

virtual void HttpGet::postGetHook ( QNetworkReply *  reply)
inlineprotectedvirtual

Hook called after the GET reply is received.

Parameters
replyThe network reply object.

Definition at line 51 of file httpget.h.

◆ postReplyHook()

virtual void HttpGet::postReplyHook ( QNetworkReply *  reply)
overrideprotectedvirtual

Hook called after the network reply is processed.

Parameters
replyThe network reply object.

Reimplemented from HttpOperation.

◆ preGetHook()

virtual void HttpGet::preGetHook ( QNetworkRequest *  )
inlineprotectedvirtual

Hook called before the GET request is sent.

Definition at line 47 of file httpget.h.

◆ setStreamingRead()

void HttpGet::setStreamingRead ( bool  value)
inline

Enable or disable streaming read mode.

Parameters
valueTrue to enable streaming reads via the dataAvailable() signal.

Definition at line 30 of file httpget.h.

◆ streamingRead()

bool HttpGet::streamingRead ( ) const
inline

streamingRead Set to true to return the response piece by piece as available using the dataAvailable() signal

Returns
True if streaming read mode is enabled.

Definition at line 26 of file httpget.h.


The documentation for this class was generated from the following file: