network access manager for QGIS
This class implements the QGIS network access manager. It's a singleton that can be used across QGIS.
Plugins can insert proxy factories and thereby redirect requests to individual proxies.
If no proxy factories are there or none returns a proxy for an URL a fallback proxy can be set. There's also a exclude list that defines URLs that the fallback proxy should not be used for, then no proxy will be used.
- Since
- 1.5
Definition at line 269 of file qgsnetworkaccessmanager.h.
QgsNetworkReplyContent QgsNetworkAccessManager::blockingGet |
( |
QNetworkRequest & |
request, |
|
|
const QString & |
authCfg = QString() , |
|
|
bool |
forceRefresh = false , |
|
|
QgsFeedback * |
feedback = nullptr |
|
) |
| |
|
static |
Posts a GET request to obtain the contents of the target request and returns a new QgsNetworkReplyContent object for reading.
The current thread will be blocked until the request is returned.
This method is safe to call in either the main thread or a worker thread.
If forceRefresh is false
then previously cached replies may be used for the request. If it is set to true
then a new query is always performed.
If an authCfg has been specified, then that authentication configuration required will automatically be applied to request. There is no need to manually apply the authentication to the request prior to calling this method.
The optional feedback argument can be used to abort ongoing requests.
The contents of the reply will be returned after the request is completed or an error occurs.
- See also
- blockingPost()
- Since
- QGIS 3.6
Definition at line 780 of file qgsnetworkaccessmanager.cpp.
QgsNetworkReplyContent QgsNetworkAccessManager::blockingPost |
( |
QNetworkRequest & |
request, |
|
|
const QByteArray & |
data, |
|
|
const QString & |
authCfg = QString() , |
|
|
bool |
forceRefresh = false , |
|
|
QgsFeedback * |
feedback = nullptr |
|
) |
| |
|
static |
Posts a POST request to obtain the contents of the target request, using the given data, and returns a new QgsNetworkReplyContent object for reading.
The current thread will be blocked until the request is returned.
This method is safe to call in either the main thread or a worker thread.
If forceRefresh is false
then previously cached replies may be used for the request. If it is set to true
then a new query is always performed.
If an authCfg has been specified, then that authentication configuration required will automatically be applied to request. There is no need to manually apply the authentication to the request prior to calling this method.
The optional feedback argument can be used to abort ongoing requests.
The contents of the reply will be returned after the request is completed or an error occurs.
- See also
- blockingGet()
- Since
- QGIS 3.6
Definition at line 788 of file qgsnetworkaccessmanager.cpp.
void QgsNetworkAccessManager::downloadProgress |
( |
int |
requestId, |
|
|
qint64 |
bytesReceived, |
|
|
qint64 |
bytesTotal |
|
) |
| |
|
signal |
Emitted when a network reply receives a progress report.
The requestId argument reflects the unique ID identifying the original request which the progress report relates to.
The bytesReceived parameter indicates the number of bytes received, while bytesTotal indicates the total number of bytes expected to be downloaded. If the number of bytes to be downloaded is not known, bytesTotal will be -1.
This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary only to connect to the main thread's signal in order to receive notifications about requests created in any thread.
- Since
- QGIS 3.6
void QgsNetworkAccessManager::requestAuthDetailsAdded |
( |
int |
requestId, |
|
|
const QString & |
realm, |
|
|
const QString & |
user, |
|
|
const QString & |
password |
|
) |
| |
|
signal |
Emitted when network authentication details have been added to a request.
The requestId argument reflects the unique ID identifying the original request which the authentication relates to.
This signal is always sent from the main thread QgsNetworkAccessManager instance, so it is necessary only to connect to the main thread's signal in order to receive notifications about authentication requests from any thread.
This signal is for debugging and logging purposes only, and should not be used to respond to the requests. See QgsNetworkAuthenticationHandler for details on how to handle authentication requests.
- See also
- requestRequiresAuth()
- Since
- QGIS 3.6
void QgsNetworkAccessManager::requestEncounteredSslErrors |
( |
int |
requestId, |
|
|
const QList< QSslError > & |
errors |
|
) |
| |
|
signal |
Emitted when a network request encounters SSL errors.
The requestId argument reflects the unique ID identifying the original request which the SSL error relates to.
This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary only to connect to the main thread's signal in order to receive notifications about SSL errors from any thread.
This signal is for debugging and logging purposes only, and cannot be used to respond to the errors. See QgsSslErrorHandler for details on how to handle SSL errors and potentially ignore them.
- Since
- QGIS 3.6
void QgsNetworkAccessManager::requestRequiresAuth |
( |
int |
requestId, |
|
|
const QString & |
realm |
|
) |
| |
|
signal |
Emitted when a network request prompts an authentication request.
The requestId argument reflects the unique ID identifying the original request which the authentication relates to.
This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary only to connect to the main thread's signal in order to receive notifications about authentication requests from any thread.
This signal is for debugging and logging purposes only, and cannot be used to respond to the requests. See QgsNetworkAuthenticationHandler for details on how to handle authentication requests.
- See also
- requestAuthDetailsAdded()
- Since
- QGIS 3.6
Sets the application network authentication handler, which is used to respond to network authentication prompts during network requests.
Ownership of handler is transferred to the main thread QgsNetworkAccessManager instance.
This method must ONLY be called on the main thread QgsNetworkAccessManager. It is not necessary to set handlers for background threads – the main thread QgsNetworkAuthenticationHandler will automatically be used in a thread-safe manner for any authentication requests encountered on background threads.
The default QgsNetworkAuthenticationHandler responds to request only by logging the request, but does not provide any username or password resolution.
- Note
- Not available in Python bindings.
- Since
- QGIS 3.6
Definition at line 223 of file qgsnetworkaccessmanager.cpp.
void QgsNetworkAccessManager::setSslErrorHandler |
( |
std::unique_ptr< QgsSslErrorHandler > |
handler | ) |
|
Sets the application SSL error handler, which is used to respond to SSL errors encountered during network requests.
Ownership of handler is transferred to the main thread QgsNetworkAccessManager instance.
This method must ONLY be called on the main thread QgsNetworkAccessManager. It is not necessary to set handlers for background threads – the main thread QgsSslErrorHandler will automatically be used in a thread-safe manner for any SSL errors encountered on background threads.
The default QgsSslErrorHandler responds to SSL errors only by logging the errors, and uses the default Qt response, which is to abort the request.
- Note
- Not available in Python bindings.
- Since
- QGIS 3.6
Definition at line 217 of file qgsnetworkaccessmanager.cpp.