mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-03 00:04:47 -04:00
[api] Introduce flag to disable error message logging for network requests
Fixes #53721
This commit is contained in:
parent
4b3ac09b74
commit
d9362e6687
@ -75,6 +75,20 @@ Qgis.Critical = Qgis.MessageLevel.Critical
|
|||||||
Qgis.Success = Qgis.MessageLevel.Success
|
Qgis.Success = Qgis.MessageLevel.Success
|
||||||
Qgis.NoLevel = Qgis.MessageLevel.NoLevel
|
Qgis.NoLevel = Qgis.MessageLevel.NoLevel
|
||||||
Qgis.MessageLevel.baseClass = Qgis
|
Qgis.MessageLevel.baseClass = Qgis
|
||||||
|
# monkey patching scoped based enum
|
||||||
|
Qgis.NetworkRequestFlag.DisableMessageLogging.__doc__ = "If present, indicates that no message logging should be performed when network errors are encountered"
|
||||||
|
Qgis.NetworkRequestFlag.__doc__ = """Flags controlling behavior of network requests.
|
||||||
|
|
||||||
|
.. versionadded:: 4.0
|
||||||
|
|
||||||
|
* ``DisableMessageLogging``: If present, indicates that no message logging should be performed when network errors are encountered
|
||||||
|
|
||||||
|
"""
|
||||||
|
# --
|
||||||
|
Qgis.NetworkRequestFlag.baseClass = Qgis
|
||||||
|
Qgis.NetworkRequestFlags = lambda flags=0: Qgis.NetworkRequestFlag(flags)
|
||||||
|
Qgis.NetworkRequestFlags.baseClass = Qgis
|
||||||
|
NetworkRequestFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
|
||||||
QgsMapLayer.LayerType = Qgis.LayerType
|
QgsMapLayer.LayerType = Qgis.LayerType
|
||||||
# monkey patching scoped based enum
|
# monkey patching scoped based enum
|
||||||
QgsMapLayer.VectorLayer = Qgis.LayerType.Vector
|
QgsMapLayer.VectorLayer = Qgis.LayerType.Vector
|
||||||
|
@ -50,13 +50,22 @@ copy and pass between threads without issue.
|
|||||||
typedef QFlags<QgsBlockingNetworkRequest::RequestFlag> RequestFlags;
|
typedef QFlags<QgsBlockingNetworkRequest::RequestFlag> RequestFlags;
|
||||||
|
|
||||||
|
|
||||||
explicit QgsBlockingNetworkRequest();
|
explicit QgsBlockingNetworkRequest( Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsBlockingNetworkRequest
|
Constructor for QgsBlockingNetworkRequest.
|
||||||
|
|
||||||
|
The ``flags`` argument was added in QGIS 4.0
|
||||||
%End
|
%End
|
||||||
|
|
||||||
~QgsBlockingNetworkRequest();
|
~QgsBlockingNetworkRequest();
|
||||||
|
|
||||||
|
Qgis::NetworkRequestFlags flags() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the network request flags.
|
||||||
|
|
||||||
|
.. versionadded:: 4.0
|
||||||
|
%End
|
||||||
|
|
||||||
ErrorCode get( QNetworkRequest &request, bool forceRefresh = false, QgsFeedback *feedback = 0, RequestFlags requestFlags = QgsBlockingNetworkRequest::RequestFlags() );
|
ErrorCode get( QNetworkRequest &request, bool forceRefresh = false, QgsFeedback *feedback = 0, RequestFlags requestFlags = QgsBlockingNetworkRequest::RequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Performs a "get" operation on the specified ``request``.
|
Performs a "get" operation on the specified ``request``.
|
||||||
|
@ -284,7 +284,7 @@ If set to 0, no timeout is set.
|
|||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
%End
|
%End
|
||||||
|
|
||||||
static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0 );
|
static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0, Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Posts a GET request to obtain the contents of the target request and
|
Posts a GET request to obtain the contents of the target request and
|
||||||
returns a new :py:class:`QgsNetworkReplyContent` object for reading. The
|
returns a new :py:class:`QgsNetworkReplyContent` object for reading. The
|
||||||
@ -308,12 +308,14 @@ requests.
|
|||||||
The contents of the reply will be returned after the request is
|
The contents of the reply will be returned after the request is
|
||||||
completed or an error occurs.
|
completed or an error occurs.
|
||||||
|
|
||||||
|
The ``flags`` argument was added in QGIS 4.0.
|
||||||
|
|
||||||
.. seealso:: :py:func:`blockingPost`
|
.. seealso:: :py:func:`blockingPost`
|
||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
%End
|
%End
|
||||||
|
|
||||||
static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0 );
|
static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0, Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Posts a POST request to obtain the contents of the target ``request``,
|
Posts a POST request to obtain the contents of the target ``request``,
|
||||||
using the given ``data``, and returns a new
|
using the given ``data``, and returns a new
|
||||||
@ -338,6 +340,8 @@ requests.
|
|||||||
The contents of the reply will be returned after the request is
|
The contents of the reply will be returned after the request is
|
||||||
completed or an error occurs.
|
completed or an error occurs.
|
||||||
|
|
||||||
|
The ``flags`` argument was added in QGIS 4.0.
|
||||||
|
|
||||||
.. seealso:: :py:func:`blockingGet`
|
.. seealso:: :py:func:`blockingGet`
|
||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
|
@ -121,6 +121,14 @@ The development version
|
|||||||
NoLevel,
|
NoLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class NetworkRequestFlag /BaseType=IntFlag/
|
||||||
|
{
|
||||||
|
DisableMessageLogging,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QFlags<Qgis::NetworkRequestFlag> NetworkRequestFlags;
|
||||||
|
|
||||||
|
|
||||||
enum class LayerType /BaseType=IntEnum/
|
enum class LayerType /BaseType=IntEnum/
|
||||||
{
|
{
|
||||||
Vector,
|
Vector,
|
||||||
@ -3553,6 +3561,8 @@ PROJ4 string that represents a geographic coord system.
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
QFlags<Qgis::NetworkRequestFlag> operator|(Qgis::NetworkRequestFlag f1, QFlags<Qgis::NetworkRequestFlag> f2);
|
||||||
|
|
||||||
QFlags<Qgis::AnnotationItemFlag> operator|(Qgis::AnnotationItemFlag f1, QFlags<Qgis::AnnotationItemFlag> f2);
|
QFlags<Qgis::AnnotationItemFlag> operator|(Qgis::AnnotationItemFlag f1, QFlags<Qgis::AnnotationItemFlag> f2);
|
||||||
|
|
||||||
QFlags<Qgis::AnnotationItemGuiFlag> operator|(Qgis::AnnotationItemGuiFlag f1, QFlags<Qgis::AnnotationItemGuiFlag> f2);
|
QFlags<Qgis::AnnotationItemGuiFlag> operator|(Qgis::AnnotationItemGuiFlag f1, QFlags<Qgis::AnnotationItemGuiFlag> f2);
|
||||||
|
@ -69,6 +69,19 @@ Qgis.AuthConfigurationStorageCapability.baseClass = Qgis
|
|||||||
Qgis.AuthConfigurationStorageCapabilities.baseClass = Qgis
|
Qgis.AuthConfigurationStorageCapabilities.baseClass = Qgis
|
||||||
AuthConfigurationStorageCapabilities = Qgis # dirty hack since SIP seems to introduce the flags in module
|
AuthConfigurationStorageCapabilities = Qgis # dirty hack since SIP seems to introduce the flags in module
|
||||||
Qgis.MessageLevel.baseClass = Qgis
|
Qgis.MessageLevel.baseClass = Qgis
|
||||||
|
# monkey patching scoped based enum
|
||||||
|
Qgis.NetworkRequestFlag.DisableMessageLogging.__doc__ = "If present, indicates that no message logging should be performed when network errors are encountered"
|
||||||
|
Qgis.NetworkRequestFlag.__doc__ = """Flags controlling behavior of network requests.
|
||||||
|
|
||||||
|
.. versionadded:: 4.0
|
||||||
|
|
||||||
|
* ``DisableMessageLogging``: If present, indicates that no message logging should be performed when network errors are encountered
|
||||||
|
|
||||||
|
"""
|
||||||
|
# --
|
||||||
|
Qgis.NetworkRequestFlag.baseClass = Qgis
|
||||||
|
Qgis.NetworkRequestFlags.baseClass = Qgis
|
||||||
|
NetworkRequestFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
|
||||||
QgsMapLayer.LayerType = Qgis.LayerType
|
QgsMapLayer.LayerType = Qgis.LayerType
|
||||||
# monkey patching scoped based enum
|
# monkey patching scoped based enum
|
||||||
QgsMapLayer.VectorLayer = Qgis.LayerType.Vector
|
QgsMapLayer.VectorLayer = Qgis.LayerType.Vector
|
||||||
|
@ -50,13 +50,22 @@ copy and pass between threads without issue.
|
|||||||
typedef QFlags<QgsBlockingNetworkRequest::RequestFlag> RequestFlags;
|
typedef QFlags<QgsBlockingNetworkRequest::RequestFlag> RequestFlags;
|
||||||
|
|
||||||
|
|
||||||
explicit QgsBlockingNetworkRequest();
|
explicit QgsBlockingNetworkRequest( Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsBlockingNetworkRequest
|
Constructor for QgsBlockingNetworkRequest.
|
||||||
|
|
||||||
|
The ``flags`` argument was added in QGIS 4.0
|
||||||
%End
|
%End
|
||||||
|
|
||||||
~QgsBlockingNetworkRequest();
|
~QgsBlockingNetworkRequest();
|
||||||
|
|
||||||
|
Qgis::NetworkRequestFlags flags() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the network request flags.
|
||||||
|
|
||||||
|
.. versionadded:: 4.0
|
||||||
|
%End
|
||||||
|
|
||||||
ErrorCode get( QNetworkRequest &request, bool forceRefresh = false, QgsFeedback *feedback = 0, RequestFlags requestFlags = QgsBlockingNetworkRequest::RequestFlags() );
|
ErrorCode get( QNetworkRequest &request, bool forceRefresh = false, QgsFeedback *feedback = 0, RequestFlags requestFlags = QgsBlockingNetworkRequest::RequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Performs a "get" operation on the specified ``request``.
|
Performs a "get" operation on the specified ``request``.
|
||||||
|
@ -284,7 +284,7 @@ If set to 0, no timeout is set.
|
|||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
%End
|
%End
|
||||||
|
|
||||||
static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0 );
|
static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0, Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Posts a GET request to obtain the contents of the target request and
|
Posts a GET request to obtain the contents of the target request and
|
||||||
returns a new :py:class:`QgsNetworkReplyContent` object for reading. The
|
returns a new :py:class:`QgsNetworkReplyContent` object for reading. The
|
||||||
@ -308,12 +308,14 @@ requests.
|
|||||||
The contents of the reply will be returned after the request is
|
The contents of the reply will be returned after the request is
|
||||||
completed or an error occurs.
|
completed or an error occurs.
|
||||||
|
|
||||||
|
The ``flags`` argument was added in QGIS 4.0.
|
||||||
|
|
||||||
.. seealso:: :py:func:`blockingPost`
|
.. seealso:: :py:func:`blockingPost`
|
||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
%End
|
%End
|
||||||
|
|
||||||
static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0 );
|
static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0, Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
%Docstring
|
%Docstring
|
||||||
Posts a POST request to obtain the contents of the target ``request``,
|
Posts a POST request to obtain the contents of the target ``request``,
|
||||||
using the given ``data``, and returns a new
|
using the given ``data``, and returns a new
|
||||||
@ -338,6 +340,8 @@ requests.
|
|||||||
The contents of the reply will be returned after the request is
|
The contents of the reply will be returned after the request is
|
||||||
completed or an error occurs.
|
completed or an error occurs.
|
||||||
|
|
||||||
|
The ``flags`` argument was added in QGIS 4.0.
|
||||||
|
|
||||||
.. seealso:: :py:func:`blockingGet`
|
.. seealso:: :py:func:`blockingGet`
|
||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
|
@ -121,6 +121,14 @@ The development version
|
|||||||
NoLevel,
|
NoLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class NetworkRequestFlag
|
||||||
|
{
|
||||||
|
DisableMessageLogging,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QFlags<Qgis::NetworkRequestFlag> NetworkRequestFlags;
|
||||||
|
|
||||||
|
|
||||||
enum class LayerType
|
enum class LayerType
|
||||||
{
|
{
|
||||||
Vector,
|
Vector,
|
||||||
@ -3553,6 +3561,8 @@ PROJ4 string that represents a geographic coord system.
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
QFlags<Qgis::NetworkRequestFlag> operator|(Qgis::NetworkRequestFlag f1, QFlags<Qgis::NetworkRequestFlag> f2);
|
||||||
|
|
||||||
QFlags<Qgis::AnnotationItemFlag> operator|(Qgis::AnnotationItemFlag f1, QFlags<Qgis::AnnotationItemFlag> f2);
|
QFlags<Qgis::AnnotationItemFlag> operator|(Qgis::AnnotationItemFlag f1, QFlags<Qgis::AnnotationItemFlag> f2);
|
||||||
|
|
||||||
QFlags<Qgis::AnnotationItemGuiFlag> operator|(Qgis::AnnotationItemGuiFlag f1, QFlags<Qgis::AnnotationItemGuiFlag> f2);
|
QFlags<Qgis::AnnotationItemGuiFlag> operator|(Qgis::AnnotationItemGuiFlag f1, QFlags<Qgis::AnnotationItemGuiFlag> f2);
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
#include <QAuthenticator>
|
#include <QAuthenticator>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
QgsBlockingNetworkRequest::QgsBlockingNetworkRequest()
|
QgsBlockingNetworkRequest::QgsBlockingNetworkRequest( Qgis::NetworkRequestFlags flags )
|
||||||
|
: mFlags( flags )
|
||||||
{
|
{
|
||||||
connect( QgsNetworkAccessManager::instance(), qOverload< QNetworkReply * >( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsBlockingNetworkRequest::requestTimedOut );
|
connect( QgsNetworkAccessManager::instance(), qOverload< QNetworkReply * >( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsBlockingNetworkRequest::requestTimedOut );
|
||||||
}
|
}
|
||||||
@ -146,7 +147,10 @@ QgsBlockingNetworkRequest::ErrorCode QgsBlockingNetworkRequest::doRequest( Qgis:
|
|||||||
{
|
{
|
||||||
mErrorCode = NetworkError;
|
mErrorCode = NetworkError;
|
||||||
mErrorMessage = errorMessageFailedAuth();
|
mErrorMessage = errorMessageFailedAuth();
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
return NetworkError;
|
return NetworkError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +190,10 @@ QgsBlockingNetworkRequest::ErrorCode QgsBlockingNetworkRequest::doRequest( Qgis:
|
|||||||
{
|
{
|
||||||
mErrorCode = NetworkError;
|
mErrorCode = NetworkError;
|
||||||
mErrorMessage = errorMessageFailedAuth();
|
mErrorMessage = errorMessageFailedAuth();
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
if ( requestMadeFromMainThread )
|
if ( requestMadeFromMainThread )
|
||||||
authRequestBufferNotEmpty.wakeAll();
|
authRequestBufferNotEmpty.wakeAll();
|
||||||
success = false;
|
success = false;
|
||||||
@ -353,7 +360,10 @@ void QgsBlockingNetworkRequest::replyFinished()
|
|||||||
if ( toUrl == mReply->url() )
|
if ( toUrl == mReply->url() )
|
||||||
{
|
{
|
||||||
mErrorMessage = tr( "Redirect loop detected: %1" ).arg( toUrl.toString() );
|
mErrorMessage = tr( "Redirect loop detected: %1" ).arg( toUrl.toString() );
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
mReplyContent.clear();
|
mReplyContent.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -365,7 +375,10 @@ void QgsBlockingNetworkRequest::replyFinished()
|
|||||||
mReplyContent.clear();
|
mReplyContent.clear();
|
||||||
mErrorMessage = errorMessageFailedAuth();
|
mErrorMessage = errorMessageFailedAuth();
|
||||||
mErrorCode = NetworkError;
|
mErrorCode = NetworkError;
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
emit finished();
|
emit finished();
|
||||||
Q_NOWARN_DEPRECATED_PUSH
|
Q_NOWARN_DEPRECATED_PUSH
|
||||||
emit downloadFinished();
|
emit downloadFinished();
|
||||||
@ -396,7 +409,10 @@ void QgsBlockingNetworkRequest::replyFinished()
|
|||||||
mReplyContent.clear();
|
mReplyContent.clear();
|
||||||
mErrorMessage = errorMessageFailedAuth();
|
mErrorMessage = errorMessageFailedAuth();
|
||||||
mErrorCode = NetworkError;
|
mErrorCode = NetworkError;
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
emit finished();
|
emit finished();
|
||||||
Q_NOWARN_DEPRECATED_PUSH
|
Q_NOWARN_DEPRECATED_PUSH
|
||||||
emit downloadFinished();
|
emit downloadFinished();
|
||||||
@ -455,7 +471,10 @@ void QgsBlockingNetworkRequest::replyFinished()
|
|||||||
{
|
{
|
||||||
mErrorMessage = tr( "empty response: %1" ).arg( mReply->errorString() );
|
mErrorMessage = tr( "empty response: %1" ).arg( mReply->errorString() );
|
||||||
mErrorCode = ServerExceptionError;
|
mErrorCode = ServerExceptionError;
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mReplyContent.setContent( content );
|
mReplyContent.setContent( content );
|
||||||
}
|
}
|
||||||
@ -466,7 +485,10 @@ void QgsBlockingNetworkRequest::replyFinished()
|
|||||||
{
|
{
|
||||||
mErrorMessage = mReply->errorString();
|
mErrorMessage = mReply->errorString();
|
||||||
mErrorCode = ServerExceptionError;
|
mErrorCode = ServerExceptionError;
|
||||||
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
if ( !mFlags.testFlag( Qgis::NetworkRequestFlag::DisableMessageLogging ) )
|
||||||
|
{
|
||||||
|
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mReplyContent = QgsNetworkReplyContent( mReply );
|
mReplyContent = QgsNetworkReplyContent( mReply );
|
||||||
mReplyContent.setContent( mReply->readAll() );
|
mReplyContent.setContent( mReply->readAll() );
|
||||||
|
@ -71,11 +71,22 @@ class CORE_EXPORT QgsBlockingNetworkRequest : public QObject
|
|||||||
Q_DECLARE_FLAGS( RequestFlags, RequestFlag )
|
Q_DECLARE_FLAGS( RequestFlags, RequestFlag )
|
||||||
Q_FLAG( RequestFlags )
|
Q_FLAG( RequestFlags )
|
||||||
|
|
||||||
//! Constructor for QgsBlockingNetworkRequest
|
/**
|
||||||
explicit QgsBlockingNetworkRequest();
|
* Constructor for QgsBlockingNetworkRequest.
|
||||||
|
*
|
||||||
|
* The \a flags argument was added in QGIS 4.0
|
||||||
|
*/
|
||||||
|
explicit QgsBlockingNetworkRequest( Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
|
|
||||||
~QgsBlockingNetworkRequest() override;
|
~QgsBlockingNetworkRequest() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the network request flags.
|
||||||
|
*
|
||||||
|
* \since QGIS 4.0
|
||||||
|
*/
|
||||||
|
Qgis::NetworkRequestFlags flags() const { return mFlags; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a "get" operation on the specified \a request.
|
* Performs a "get" operation on the specified \a request.
|
||||||
*
|
*
|
||||||
@ -258,6 +269,8 @@ class CORE_EXPORT QgsBlockingNetworkRequest : public QObject
|
|||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
Qgis::NetworkRequestFlags mFlags;
|
||||||
|
|
||||||
//! The reply to the request
|
//! The reply to the request
|
||||||
QNetworkReply *mReply = nullptr;
|
QNetworkReply *mReply = nullptr;
|
||||||
|
|
||||||
|
@ -801,17 +801,17 @@ void QgsNetworkAccessManager::setTimeout( const int time )
|
|||||||
settingsNetworkTimeout->setValue( time );
|
settingsNetworkTimeout->setValue( time );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsNetworkReplyContent QgsNetworkAccessManager::blockingGet( QNetworkRequest &request, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback )
|
QgsNetworkReplyContent QgsNetworkAccessManager::blockingGet( QNetworkRequest &request, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback, Qgis::NetworkRequestFlags flags )
|
||||||
{
|
{
|
||||||
QgsBlockingNetworkRequest br;
|
QgsBlockingNetworkRequest br( flags );
|
||||||
br.setAuthCfg( authCfg );
|
br.setAuthCfg( authCfg );
|
||||||
br.get( request, forceRefresh, feedback );
|
br.get( request, forceRefresh, feedback );
|
||||||
return br.reply();
|
return br.reply();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsNetworkReplyContent QgsNetworkAccessManager::blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback )
|
QgsNetworkReplyContent QgsNetworkAccessManager::blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback, Qgis::NetworkRequestFlags flags )
|
||||||
{
|
{
|
||||||
QgsBlockingNetworkRequest br;
|
QgsBlockingNetworkRequest br( flags );
|
||||||
br.setAuthCfg( authCfg );
|
br.setAuthCfg( authCfg );
|
||||||
br.post( request, data, forceRefresh, feedback );
|
br.post( request, data, forceRefresh, feedback );
|
||||||
return br.reply();
|
return br.reply();
|
||||||
|
@ -477,10 +477,12 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
|
|||||||
*
|
*
|
||||||
* The contents of the reply will be returned after the request is completed or an error occurs.
|
* The contents of the reply will be returned after the request is completed or an error occurs.
|
||||||
*
|
*
|
||||||
|
* The \a flags argument was added in QGIS 4.0.
|
||||||
|
*
|
||||||
* \see blockingPost()
|
* \see blockingPost()
|
||||||
* \since QGIS 3.6
|
* \since QGIS 3.6
|
||||||
*/
|
*/
|
||||||
static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = nullptr );
|
static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = nullptr, Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts a POST request to obtain the contents of the target \a request, using the given \a data, and returns a new
|
* Posts a POST request to obtain the contents of the target \a request, using the given \a data, and returns a new
|
||||||
@ -499,10 +501,12 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
|
|||||||
*
|
*
|
||||||
* The contents of the reply will be returned after the request is completed or an error occurs.
|
* The contents of the reply will be returned after the request is completed or an error occurs.
|
||||||
*
|
*
|
||||||
|
* The \a flags argument was added in QGIS 4.0.
|
||||||
|
*
|
||||||
* \see blockingGet()
|
* \see blockingGet()
|
||||||
* \since QGIS 3.6
|
* \since QGIS 3.6
|
||||||
*/
|
*/
|
||||||
static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = nullptr );
|
static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = nullptr, Qgis::NetworkRequestFlags flags = Qgis::NetworkRequestFlags() );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a request pre-processor function, which allows manipulation of a network request before it is processed.
|
* Sets a request pre-processor function, which allows manipulation of a network request before it is processed.
|
||||||
|
@ -161,6 +161,25 @@ class CORE_EXPORT Qgis
|
|||||||
};
|
};
|
||||||
Q_ENUM( MessageLevel )
|
Q_ENUM( MessageLevel )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Flags controlling behavior of network requests.
|
||||||
|
*
|
||||||
|
* \since QGIS 4.0
|
||||||
|
*/
|
||||||
|
enum class NetworkRequestFlag : int SIP_ENUM_BASETYPE( IntFlag )
|
||||||
|
{
|
||||||
|
DisableMessageLogging = 1 << 0, //!< If present, indicates that no message logging should be performed when network errors are encountered
|
||||||
|
};
|
||||||
|
Q_ENUM( NetworkRequestFlag )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Flags controlling behavior of network requests.
|
||||||
|
*
|
||||||
|
* \since QGIS 3.40
|
||||||
|
*/
|
||||||
|
Q_DECLARE_FLAGS( NetworkRequestFlags, NetworkRequestFlag )
|
||||||
|
Q_FLAG( NetworkRequestFlags )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of layers that can be added to a map
|
* Types of layers that can be added to a map
|
||||||
*
|
*
|
||||||
@ -6236,6 +6255,7 @@ class CORE_EXPORT Qgis
|
|||||||
QHASH_FOR_CLASS_ENUM( Qgis::CaptureTechnique )
|
QHASH_FOR_CLASS_ENUM( Qgis::CaptureTechnique )
|
||||||
QHASH_FOR_CLASS_ENUM( Qgis::RasterAttributeTableFieldUsage )
|
QHASH_FOR_CLASS_ENUM( Qgis::RasterAttributeTableFieldUsage )
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::NetworkRequestFlags )
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AnnotationItemFlags )
|
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AnnotationItemFlags )
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AnnotationItemGuiFlags )
|
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AnnotationItemGuiFlags )
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AuthConfigurationStorageCapabilities )
|
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AuthConfigurationStorageCapabilities )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user