The proxy settings are only set up for core class in QGIS, which you should look at to make your requests. CF https://gis.stackexchange.com/questions/343126/how-to-perform-sync-or-async-network-request-in-pyqgis
If you really want to use "requests", you should read the QgsSettings about proxy and use these values in requests as well. Similar to https://stackoverflow.com/questions/23041066/setting-proxy-parameter-in-qgis-plugins-how-to/37757921#37757921 Le jeu. 21 janv. 2021 à 15:03, Sampo Savolainen < [email protected]> a écrit : > Hi, > > I'm developing a small QGIS plugin ( > https://github.com/spatineo/qgis-intelligent-search/) and ran into issues > with proxy configuration. The plugin uses the Python requests library to > make HTTP API calls and owslib to download and parse GetCapabilities > documents from WxS services. Owslib seems to use the same requests library > to make HTTP calls. However proxies are (unsurprisingly) giving us > headaches. > > We have tested the plugin in two environments where proxies are required > to make HTTP requests. The environments had different versions of QGIS: > 3.14 and 3.10, both in Windows. The first environment (newer version) is > able to make the API calls using the requests library, but owslib fails to > connect to services. The older version of QGIS fails to connect to the API > and the owslib part never gets tested. Note that this discrepancy may be > related to the API being available without a proxy in the first > environment - though this is just a suspicion, I have been unable to > confirm this. > > With 3.10, I've tried QGIS proxy configuration both as "DefaultProxy" (use > system config) and as "HttpProxy" but neither one helped. However I was > able to make it work by setting the http_proxy and https_proxy environment > variables in a shell and launching QGIS from that shell. > > So this seems to boil down to the QGIS proxy settings are not passed to > the plugin via http_proxy and https_proxy environment variables. Is there a > best practice on how plugins should access proxy configuration in QGIS and > use it? > > > Thanks, > Sampo > > -- > Sampo Savolainen > Managing Director > Työpajankatu 9 D, 00580 Helsinki, Finland > www.spatineo.com > Tel. +358 40 7555 649 > > > > This message may contain privileged and/or confidential information. If > you have received this e-mail in error or are not the intended recipient, > you may not use, copy, disseminate, or distribute it; do not open > any attachments, delete it immediately from your system and notify the > sender promptly by e-mail that you have done so. > _______________________________________________ > QGIS-Developer mailing list > [email protected] > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
