Open rduivenvoorde opened 6 years ago
@rduivenvoorde may you explain "have api for handling the QgsAuthenticationManager (maybe even a way for handling/showing the authentication dialogs?)"
@luipir I was thinking about showing the widgets (if not set yet), like asking for a master password, or just asking for a password. Though that probably should not be the responsibiliy of QgsNetworkAccessManager
QGIS Enhancement: Title
Date 2018/04/19
Author Richard Duivenvoorde (@rduivenvoorde)
Contact richard@duif.net
maintainer @user
Version QGIS 3.x
Summary
Currently developers (both py and cpp) can use QgsNetworkAccessManager to do their network related actions:
https://qgis.org/api/classQgsNetworkAccessManager.html
It is a very thin wrapper around QtNetworkAccessManager
http://doc.qt.io/qt-5/qnetworkaccessmanager.html
If I'm correct, the Qgs-version adds:
Python plugin developers, often use other Network related libraries to do requests to webservices (modules like http2, requests etc). Thereby often 'forgetting' about proxies and QGIS-own authentication framework.
Alessandro/Boundless for QGIS2 introduced a Python NetworkAccessManager, mimicking the http2 api:
https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py
While this module mostly works in QGIS3 too, I think it is nicer to actually add some of these utility methods to core QgsNetworkAccessManager class.
In this way it is natively available for Python developers, and they do not have to depend on external libraries. It also brings (hopefully) the right way of threading to a larger audience (https://github.com/qgis/QGIS-Enhancement-Proposals/issues/122#issuecomment-382983640)
Proposed Solution
Some nice to have things:
let user choose between a synchronous (blocking) and asynchronous (non-blocking) request (eg handy for locatorfilter implementations (https://qgis.org/api/classQgsLocatorFilter.html))
handle Timeouts better (= implement the timers in the class and throw exceptions, instead of have to implement them yourself?)
be able to override(!) the settings Timeout (so you can create a fast-timing-out request, while in QGIS Settings you have a Timeout of 60 seconds (OR the other way around)
handle redirects properly (see networkaccessmanager.py)
set proper (custom) headers (referrer, User-Agent etc)
better reporting of exceptions (maybe better mapping of the Qt-exception numbers?)
have api for handling the QgsAuthenticationManager (maybe even a way for handling/showing the authentication dialogs?)
maybe resembling/learning api from Requests or Http2 modules
proper python bindings, tests and documentation
Example(s)
See for example: http://docs.python-requests.org/en/master/
And the boundless NAM https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py
Performance Implications
None
Backwards Compatibility
(required)
Votes
(required)