302 void setSslErrorHandler( std::unique_ptr< QgsSslErrorHandler > handler );
320 void setAuthHandler( std::unique_ptr< QgsNetworkAuthenticationHandler > handler );
331 void insertProxyFactory( QNetworkProxyFactory *factory
SIP_TRANSFER );
347 const QList<QNetworkProxyFactory *> proxyFactories()
const;
357 const QNetworkProxy &fallbackProxy()
const;
368 QStringList excludeList()
const;
379 QStringList noProxyList()
const;
392 void setFallbackProxyAndExcludes(
const QNetworkProxy &proxy,
const QStringList &excludes,
const QStringList &noProxyURLs );
399 static QString cacheLoadControlName( QNetworkRequest::CacheLoadControl control );
406 static QNetworkRequest::CacheLoadControl cacheLoadControlFromName(
const QString &name );
415 void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
452 static int timeout();
461 static void setTimeout(
int time );
483 static QgsNetworkReplyContent blockingGet( QNetworkRequest &request,
const QString &authCfg = QString(),
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
505 static QgsNetworkReplyContent blockingPost( QNetworkRequest &request,
const QByteArray &data,
const QString &authCfg = QString(),
bool forceRefresh =
false,
QgsFeedback *feedback =
nullptr );
519 static QString setRequestPreprocessor(
const std::function<
void( QNetworkRequest *request )> &processor );
521 static QString setRequestPreprocessor( SIP_PYCALLABLE / AllowNone / );
526 Py_BEGIN_ALLOW_THREADS
531 PyObject *s = sipCallMethod( NULL, a0,
"D", arg, sipType_QNetworkRequest, NULL );
534 QString *t1 =
reinterpret_cast<QString *
>( sipConvertToType( s, sipType_QString, 0, SIP_NOT_NONE, &state, &sipIsError ) );
535 if ( sipIsError == 0 )
537 res = QString( *t1 );
539 sipReleaseType( t1, sipType_QString, state );
545 s = sipConvertFromNewType(
new QString(
id ), sipType_QString, 0 );
561 static bool removeRequestPreprocessor(
const QString &
id );
563 static void removeRequestPreprocessor(
const QString &
id );
567 PyErr_SetString( PyExc_KeyError, QStringLiteral(
"No processor with id %1 exists." ).arg( *a0 ).toUtf8().constData() );
585 static QString setReplyPreprocessor(
const std::function<
void (
const QNetworkRequest &, QNetworkReply * )> &processor );
587 static QString setReplyPreprocessor( SIP_PYCALLABLE / AllowNone / );
592 Py_BEGIN_ALLOW_THREADS
596 Py_XDECREF( sipCallMethod( NULL, a0,
"ND",
new QNetworkRequest( request ), sipType_QNetworkRequest, NULL, reply, sipType_QNetworkReply, NULL ) );
601 s = sipConvertFromNewType(
new QString(
id ), sipType_QString, 0 );
617 static bool removeReplyPreprocessor(
const QString &
id );
619 static void removeReplyPreprocessor(
const QString &
id );
623 PyErr_SetString( PyExc_KeyError, QStringLiteral(
"No processor with id %1 exists." ).arg( *a0 ).toUtf8().constData() );
635 void requestAuthOpenBrowser(
const QUrl &url )
const;
643 void requestAuthCloseBrowser()
const;
651 void abortAuthBrowser();
664 void preprocessRequest( QNetworkRequest *req )
const;
801 void sslErrorsOccurred( QNetworkReply *,
const QList<QSslError> &errors );
802 void sslErrorsHandled( QNetworkReply *reply );
821 void authRequestOccurred( QNetworkReply *, QAuthenticator *auth );
822 void authRequestHandled( QNetworkReply *reply );
843 void onReplyFinished( QNetworkReply *reply );
845 void onReplyDownloadProgress( qint64 bytesReceived, qint64 bytesTotal );
847 void onReplySslErrors(
const QList<QSslError> &errors );
849 void handleSslErrors( QNetworkReply *reply,
const QList<QSslError> &errors );
852 void onAuthRequired( QNetworkReply *reply, QAuthenticator *auth );
853 void handleAuthRequest( QNetworkReply *reply, QAuthenticator *auth );
855 void syncCookies(
const QList<QNetworkCookie> &cookies );
858 QNetworkReply *createRequest( QNetworkAccessManager::Operation op,
const QNetworkRequest &req, QIODevice *outgoingData =
nullptr )
override;
862 void afterSslErrorHandled( QNetworkReply *reply );
865 void afterAuthRequestHandled( QNetworkReply *reply );
867 void pauseTimeout( QNetworkReply *reply );
868 void restartTimeout( QNetworkReply *reply );
869 static int getRequestId( QNetworkReply *reply );
871 QList<QNetworkProxyFactory *> mProxyFactories;
872 QNetworkProxy mFallbackProxy;
873 QStringList mExcludedURLs;
874 QStringList mNoProxyURLs;
875 bool mUseSystemProxy =
false;
876 bool mInitialized =
false;
877 bool mCacheDisabled =
false;
880 std::unique_ptr< QgsSslErrorHandler > mSslErrorHandler;
882 QSemaphore mSslErrorHandlerSemaphore;
885 std::unique_ptr< QgsNetworkAuthenticationHandler > mAuthHandler;
887 QSemaphore mAuthRequestHandlerSemaphore;
889 friend class TestQgsNetworkAccessManager;
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...