diff --git a/src/core/providers/gdal/qgsgdalprovider.cpp b/src/core/providers/gdal/qgsgdalprovider.cpp index 9783938304335..762eb91ab5f85 100644 --- a/src/core/providers/gdal/qgsgdalprovider.cpp +++ b/src/core/providers/gdal/qgsgdalprovider.cpp @@ -146,7 +146,7 @@ QgsGdalProvider::QgsGdalProvider( const QString &uri, const ProviderOptions &opt QgsGdalProviderBase::registerGdalDrivers(); #ifndef QT_NO_NETWORKPROXY - QgsGdalUtils::setupProxy(); + QgsGdalUtils::setupProxy(uri); #endif std::unique_ptr< QgsScopedRuntimeProfile > profile; @@ -3761,6 +3761,10 @@ QList QgsGdalProviderMetadata::querySublayers( const QString gdalUri = QgsGdalProvider::expandAuthConfig( uri ); QString npGdalUri = gdalUri; +#ifndef QT_NO_NETWORKPROXY + QgsGdalUtils::setupProxy(gdalUri); +#endif + QVariantMap uriParts = decodeUri( gdalUri ); // Try to open using VSIFileHandler diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index f57446b51bee0..08f8245e4626e 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -397,6 +397,10 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri, const ProviderOptions &optio { QgsApplication::registerOgrDrivers(); +#ifndef QT_NO_NETWORKPROXY + QgsGdalUtils::setupProxy(uri); +#endif + QgsSettings settings; // we always disable GDAL side shapefile encoding handling, and do it on the QGIS side. // why? it's not the ideal choice, but... @@ -407,10 +411,6 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri, const ProviderOptions &optio // a user does want/need to manually specify the encoding CPLSetConfigOption( "SHAPE_ENCODING", "" ); -#ifndef QT_NO_NETWORKPROXY - QgsGdalUtils::setupProxy(); -#endif - // make connection to the data source QgsDebugMsgLevel( "Data source uri is [" + uri + ']', 2 ); diff --git a/src/core/providers/ogr/qgsogrprovidermetadata.cpp b/src/core/providers/ogr/qgsogrprovidermetadata.cpp index b2720cc6212f8..a7086865f6708 100644 --- a/src/core/providers/ogr/qgsogrprovidermetadata.cpp +++ b/src/core/providers/ogr/qgsogrprovidermetadata.cpp @@ -1160,6 +1160,10 @@ QList QgsOgrProviderMetadata::querySublayers( const QStringList options { QStringLiteral( "@LIST_ALL_TABLES=YES" ) }; QVariantMap uriParts = decodeUri( uri ); +#ifndef QT_NO_NETWORKPROXY + QgsGdalUtils::setupProxy(uri); +#endif + // Try to open using VSIFileHandler QString vsiPrefix = QgsZipItem::vsiPrefix( uriParts.value( QStringLiteral( "path" ) ).toString() ); if ( !vsiPrefix.isEmpty() && uriParts.value( QStringLiteral( "vsiPrefix" ) ).toString().isEmpty() ) diff --git a/src/core/qgsgdalutils.cpp b/src/core/qgsgdalutils.cpp index 4590c4b5d156d..baef39ae686f2 100644 --- a/src/core/qgsgdalutils.cpp +++ b/src/core/qgsgdalutils.cpp @@ -364,8 +364,12 @@ void *QgsGdalUtils::rpcAwareCreateTransformer( GDALDatasetH hSrcDS, GDALDatasetH } #ifndef QT_NO_NETWORKPROXY -void QgsGdalUtils::setupProxy() +void QgsGdalUtils::setupProxy(const QString& uri) { + QString url = uri; + if (uri.startsWith("/vsicurl/")) { + url = uri.mid(9); + } // Check proxy configuration, they are application level but // instead of adding an API and complex signal/slot connections // given the limited cost of checking them on every provider instantiation @@ -376,7 +380,8 @@ void QgsGdalUtils::setupProxy() if ( settings.value( QStringLiteral( "proxy/proxyEnabled" ), false ).toBool() ) { // Get the first configured proxy - QList proxies( QgsNetworkAccessManager::instance()->proxyFactory()->queryProxy( ) ); + QList proxies = QNetworkProxyFactory::systemProxyForQuery( QNetworkProxyQuery( url ) ); + } if ( ! proxies.isEmpty() ) { const QNetworkProxy proxy( proxies.first() ); diff --git a/src/core/qgsgdalutils.h b/src/core/qgsgdalutils.h index e167c35f070e9..49b20f2b323a2 100644 --- a/src/core/qgsgdalutils.h +++ b/src/core/qgsgdalutils.h @@ -138,7 +138,7 @@ class CORE_EXPORT QgsGdalUtils #ifndef QT_NO_NETWORKPROXY //! Sets the gdal proxy variables - static void setupProxy(); + static void setupProxy(const QString& uri); #endif /**