15 #ifndef QGSBLOCKINGNETWORKREQUEST_H
16 #define QGSBLOCKINGNETWORKREQUEST_H
18 #include "qgis_core.h"
26 class QNetworkRequest;
85 ErrorCode get( QNetworkRequest &request,
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
107 ErrorCode post( QNetworkRequest &request,
const QByteArray &data,
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
129 ErrorCode head( QNetworkRequest &request,
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
148 ErrorCode put( QNetworkRequest &request,
const QByteArray &data,
QgsFeedback *feedback =
nullptr );
167 ErrorCode deleteResource( QNetworkRequest &request,
QgsFeedback *feedback =
nullptr );
183 QString authCfg()
const;
189 void setAuthCfg(
const QString &authCfg );
211 void replyProgress( qint64, qint64 );
212 void replyFinished();
213 void requestTimedOut( QNetworkReply *reply );
227 QNetworkReply *mReply =
nullptr;
229 Method mMethod = Get;
230 QByteArray mPayloadData;
236 QString mErrorMessage;
239 ErrorCode mErrorCode = NoError;
244 bool mIsAborted =
false;
247 bool mForceRefresh =
false;
250 bool mTimedout =
false;
253 bool mGotNonEmptyResponse =
false;
255 int mExpirationSec = 30;
257 QPointer< QgsFeedback > mFeedback;
259 ErrorCode doRequest( Method method, QNetworkRequest &request,
bool forceRefresh,
QgsFeedback *feedback =
nullptr );
261 QString errorMessageFailedAuth();
263 void sendRequestToNetworkAccessManager(
const QNetworkRequest &request );
269 class DownloaderThread :
public QThread
274 DownloaderThread(
const std::function<
void()> &
function, QObject *parent =
nullptr )
276 , mFunction( function )
286 std::function<void()> mFunction;
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
void downloadProgress(qint64, qint64)
Emitted when when data arrives during a request.
void downloadFinished()
Emitted once a request has finished downloading.
QString errorMessage() const
Returns the error message string, after a get() or post() request has been made.
@ NetworkError
A network error occurred.
@ ServerExceptionError
An exception was raised by the server.
@ NoError
No error was encountered.
@ TimeoutError
Timeout was reached before a reply was received.
QgsNetworkReplyContent reply() const
Returns the content of the network reply, after a get() or post() request has been made.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...