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 );
108 ErrorCode post( QNetworkRequest &request, QIODevice *data,
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
115 ErrorCode post( QNetworkRequest &request,
const QByteArray &data,
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
137 ErrorCode head( QNetworkRequest &request,
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
156 ErrorCode put( QNetworkRequest &request, QIODevice *data,
QgsFeedback *feedback =
nullptr );
164 ErrorCode put( QNetworkRequest &request,
const QByteArray &data,
QgsFeedback *feedback =
nullptr );
183 ErrorCode deleteResource( QNetworkRequest &request,
QgsFeedback *feedback =
nullptr );
199 QString authCfg()
const;
205 void setAuthCfg(
const QString &authCfg );
231 void uploadProgress( qint64, qint64 );
239 void replyProgress( qint64, qint64 );
240 void replyFinished();
241 void requestTimedOut( QNetworkReply *reply );
255 QNetworkReply *mReply =
nullptr;
257 Method mMethod = Get;
260 QIODevice *mPayloadData;
266 QString mErrorMessage;
269 ErrorCode mErrorCode = NoError;
274 bool mIsAborted =
false;
277 bool mForceRefresh =
false;
280 bool mTimedout =
false;
283 bool mGotNonEmptyResponse =
false;
285 int mExpirationSec = 30;
287 QPointer< QgsFeedback > mFeedback;
289 ErrorCode doRequest( Method method, QNetworkRequest &request,
bool forceRefresh,
QgsFeedback *feedback =
nullptr );
291 QString errorMessageFailedAuth();
293 void sendRequestToNetworkAccessManager(
const QNetworkRequest &request );
299 class DownloaderThread :
public QThread
304 DownloaderThread(
const std::function<
void()> &
function, QObject *parent =
nullptr )
306 , mFunction( function )
316 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.
Q_DECL_DEPRECATED 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...