28#include <QImageReader>
29#include <QRegularExpression>
30#include <QJsonParseError>
35 QUrl queryUrl( baseurl );
36 QUrlQuery query( queryUrl );
37 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
38 queryUrl.setQuery( query );
39 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
45 QUrl queryUrl( layerurl );
46 QUrlQuery query( queryUrl );
47 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
48 queryUrl.setQuery( query );
49 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
55 QUrl queryUrl( layerurl +
"/query" );
56 QUrlQuery query( queryUrl );
57 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
58 query.addQueryItem( QStringLiteral(
"where" ), whereClause.isEmpty() ? QStringLiteral(
"1=1" ) : whereClause );
59 query.addQueryItem( QStringLiteral(
"returnIdsOnly" ), QStringLiteral(
"true" ) );
62 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
65 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
66 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
68 queryUrl.setQuery( query );
69 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
75 QUrl queryUrl( layerurl +
"/query" );
76 QUrlQuery query( queryUrl );
77 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
78 query.addQueryItem( QStringLiteral(
"where" ), whereClause );
79 query.addQueryItem( QStringLiteral(
"returnExtentOnly" ), QStringLiteral(
"true" ) );
80 queryUrl.setQuery( query );
83 const QVariantMap res =
queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
86 QgsDebugError( QStringLiteral(
"getExtent failed: %1 - %2" ).arg( errorTitle, errorText ) );
94 bool fetchGeometry,
const QStringList &fetchAttributes,
95 bool fetchM,
bool fetchZ,
100 for (
const int id : objectIds )
102 ids.append( QString::number(
id ) );
104 QUrl queryUrl( layerurl +
"/query" );
105 QUrlQuery query( queryUrl );
106 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
107 query.addQueryItem( QStringLiteral(
"objectIds" ), ids.join( QLatin1Char(
',' ) ) );
108 const QString wkid =
crs.indexOf( QLatin1Char(
':' ) ) >= 0 ?
crs.split(
':' )[1] : QString();
109 query.addQueryItem( QStringLiteral(
"inSR" ), wkid );
110 query.addQueryItem( QStringLiteral(
"outSR" ), wkid );
112 query.addQueryItem( QStringLiteral(
"returnGeometry" ), fetchGeometry ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
115 if ( fetchAttributes.isEmpty() )
116 outFields = QStringLiteral(
"*" );
118 outFields = fetchAttributes.join(
',' );
119 query.addQueryItem( QStringLiteral(
"outFields" ), outFields );
121 query.addQueryItem( QStringLiteral(
"returnM" ), fetchM ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
122 query.addQueryItem( QStringLiteral(
"returnZ" ), fetchZ ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
123 if ( !filterRect.
isNull() )
125 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
126 .arg( filterRect.
xMinimum(), 0,
'f', -1 ).arg( filterRect.
yMinimum(), 0,
'f', -1 )
127 .arg( filterRect.
xMaximum(), 0,
'f', -1 ).arg( filterRect.
yMaximum(), 0,
'f', -1 ) );
128 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
129 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
131 queryUrl.setQuery( query );
132 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback );
137 QUrl queryUrl( layerurl +
"/query" );
138 QUrlQuery query( queryUrl );
139 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
140 query.addQueryItem( QStringLiteral(
"where" ), whereClause.isEmpty() ? QStringLiteral(
"1=1" ) : whereClause );
141 query.addQueryItem( QStringLiteral(
"returnIdsOnly" ), QStringLiteral(
"true" ) );
142 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
143 .arg( filterRect.
xMinimum(), 0,
'f', -1 ).arg( filterRect.
yMinimum(), 0,
'f', -1 )
144 .arg( filterRect.
xMaximum(), 0,
'f', -1 ).arg( filterRect.
yMaximum(), 0,
'f', -1 ) );
145 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
146 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
147 queryUrl.setQuery( query );
148 const QVariantMap objectIdData =
queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback );
150 if ( objectIdData.isEmpty() )
152 return QList<quint32>();
156 const QVariantList objectIdsList = objectIdData[QStringLiteral(
"objectIds" )].toList();
157 ids.reserve( objectIdsList.size() );
158 for (
const QVariant &objectId : objectIdsList )
160 ids << objectId.toInt();
169 QNetworkRequest request( url );
184 errorTitle = QStringLiteral(
"Network error" );
188 const QString content = networkRequest.
reply().
content();
189 const thread_local QRegularExpression errorRx( QStringLiteral(
"Error: <.*?>(.*?)<" ) );
190 const QRegularExpressionMatch match = errorRx.match( content );
191 if ( match.hasMatch() )
193 errorText = match.captured( 1 );
201 *contentType = content.
rawHeader(
"Content-Type" );
207 const QByteArray reply =
queryService( url, authcfg, errorTitle, errorText, requestHeaders, feedback );
208 if ( !errorTitle.isEmpty() )
210 return QVariantMap();
213 return QVariantMap();
217 const QJsonDocument doc = QJsonDocument::fromJson( reply, &err );
220 errorTitle = QStringLiteral(
"Parsing error" );
221 errorText = err.errorString();
222 QgsDebugError( QStringLiteral(
"Parsing error: %1" ).arg( err.errorString() ) );
223 return QVariantMap();
225 const QVariantMap res = doc.object().toVariantMap();
226 if ( res.contains( QStringLiteral(
"error" ) ) )
228 const QVariantMap error = res.value( QStringLiteral(
"error" ) ).toMap();
229 errorText = error.value( QStringLiteral(
"message" ) ).toString();
230 errorTitle = QObject::tr(
"Error %1" ).arg( error.value( QStringLiteral(
"code" ) ).toString() );
231 return QVariantMap();
238 if ( isTestEndpoint )
239 *isTestEndpoint =
false;
241 QUrl modifiedUrl( url );
242 if ( modifiedUrl.toString().contains( QLatin1String(
"fake_qgis_http_endpoint" ) ) )
244 if ( isTestEndpoint )
245 *isTestEndpoint =
true;
248 QString modifiedUrlString = modifiedUrl.toString();
250 modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
251 modifiedUrlString.replace( QLatin1String(
"fake_qgis_http_endpoint/" ), QLatin1String(
"fake_qgis_http_endpoint_" ) );
253 modifiedUrlString = modifiedUrlString.mid( QStringLiteral(
"http://" ).size() );
254 QString args = modifiedUrlString.indexOf(
'?' ) >= 0 ? modifiedUrlString.mid( modifiedUrlString.indexOf(
'?' ) ) : QString();
255 if ( modifiedUrlString.size() > 150 )
257 args = QCryptographicHash::hash( args.toUtf8(), QCryptographicHash::Md5 ).toHex();
261 args.replace( QLatin1String(
"?" ), QLatin1String(
"_" ) );
262 args.replace( QLatin1String(
"&" ), QLatin1String(
"_" ) );
263 args.replace( QLatin1String(
"<" ), QLatin1String(
"_" ) );
264 args.replace( QLatin1String(
">" ), QLatin1String(
"_" ) );
265 args.replace( QLatin1String(
"'" ), QLatin1String(
"_" ) );
266 args.replace( QLatin1String(
"\"" ), QLatin1String(
"_" ) );
267 args.replace( QLatin1String(
" " ), QLatin1String(
"_" ) );
268 args.replace( QLatin1String(
":" ), QLatin1String(
"_" ) );
269 args.replace( QLatin1String(
"/" ), QLatin1String(
"_" ) );
270 args.replace( QLatin1String(
"\n" ), QLatin1String(
"_" ) );
275 if ( modifiedUrlString[1] ==
'/' )
277 modifiedUrlString = modifiedUrlString[0] +
":/" + modifiedUrlString.mid( 2 );
280 modifiedUrlString = modifiedUrlString.mid( 0, modifiedUrlString.indexOf(
'?' ) ) + args;
281 QgsDebugMsgLevel( QStringLiteral(
"Get %1 (after laundering)" ).arg( modifiedUrlString ), 2 );
282 modifiedUrl = QUrl::fromLocalFile( modifiedUrlString );
283 if ( !QFile::exists( modifiedUrlString ) )
285 QgsDebugError( QStringLiteral(
"Local test file %1 for URL %2 does not exist!!!" ).arg( modifiedUrlString, url.toString() ) );
292void QgsArcGisRestQueryUtils::adjustBaseUrl( QString &baseUrl,
const QString &name )
294 const QStringList parts = name.split(
'/' );
296 for (
const QString &part : parts )
298 if ( !checkString.isEmpty() )
299 checkString += QString(
'/' );
302 if ( baseUrl.indexOf( QRegularExpression( checkString.replace(
'/', QLatin1String(
"\\/" ) ) + QStringLiteral(
"\\/?$" ) ) ) > -1 )
304 baseUrl = baseUrl.left( baseUrl.length() - checkString.length() - 1 );
312 QString base( baseUrl );
313 bool baseChecked =
false;
314 if ( !base.endsWith(
'/' ) )
315 base += QLatin1Char(
'/' );
317 const QStringList folderList = serviceData.value( QStringLiteral(
"folders" ) ).toStringList();
318 for (
const QString &folder : folderList )
322 adjustBaseUrl( base, folder );
325 visitor( folder, base + folder );
331 QString base( baseUrl );
332 bool baseChecked =
false;
333 if ( !base.endsWith(
'/' ) )
334 base += QLatin1Char(
'/' );
336 const QVariantList serviceList = serviceData.value( QStringLiteral(
"services" ) ).toList();
337 for (
const QVariant &service : serviceList )
339 const QVariantMap serviceMap = service.toMap();
340 const QString serviceTypeString = serviceMap.value( QStringLiteral(
"type" ) ).toString();
343 switch ( serviceType )
359 const QString serviceName = serviceMap.value( QStringLiteral(
"name" ) ).toString();
360 const QString displayName = serviceName.split(
'/' ).last();
363 adjustBaseUrl( base, serviceName );
367 visitor( displayName, base + serviceName +
'/' + serviceTypeString, serviceType );
371void QgsArcGisRestQueryUtils::addLayerItems(
const std::function<
void (
const QString &,
ServiceTypeFilter,
Qgis::GeometryType,
const QString &,
const QString &,
const QString &,
const QString &,
bool,
const QString &,
const QString & )> &visitor,
const QVariantMap &serviceData,
const QString &parentUrl,
const QString &parentSupportedFormats,
const ServiceTypeFilter filter )
376 const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
377 const QStringList supportedImageFormatTypes = serviceData.value( QStringLiteral(
"supportedImageFormatTypes" ) ).toString().isEmpty() ? parentSupportedFormats.split(
',' ) : serviceData.value( QStringLiteral(
"supportedImageFormatTypes" ) ).toString().split(
',' );
378 QString format = supportedImageFormatTypes.value( 0 );
379 for (
const QString &encoding : supportedImageFormatTypes )
381 for (
const QByteArray &fmt : supportedFormats )
383 if ( encoding.startsWith( fmt, Qt::CaseInsensitive ) )
393 const QStringList capabilities = serviceData.value( QStringLiteral(
"capabilities" ) ).toString().split(
',' );
396 const bool serviceMayHaveQueryCapability = capabilities.contains( QStringLiteral(
"Query" ) ) ||
397 serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) );
399 const bool serviceMayRenderMaps = capabilities.contains( QStringLiteral(
"Map" ) ) ||
400 serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) );
402 const QVariantList layerInfoList = serviceData.value( QStringLiteral(
"layers" ) ).toList();
403 for (
const QVariant &layerInfo : layerInfoList )
405 const QVariantMap layerInfoMap = layerInfo.toMap();
406 const QString
id = layerInfoMap.value( QStringLiteral(
"id" ) ).toString();
407 const QString parentLayerId = layerInfoMap.value( QStringLiteral(
"parentLayerId" ) ).toString();
408 const QString name = layerInfoMap.value( QStringLiteral(
"name" ) ).toString();
409 const QString description = layerInfoMap.value( QStringLiteral(
"description" ) ).toString();
414 if ( !layerInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
426 const QString geometryType = layerInfoMap.value( QStringLiteral(
"geometryType" ) ).toString();
437 if ( serviceMayRenderMaps )
439 if ( geometryType.isEmpty() )
447 if ( !layerInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
458 const QVariantList tableInfoList = serviceData.value( QStringLiteral(
"tables" ) ).toList();
459 for (
const QVariant &tableInfo : tableInfoList )
461 const QVariantMap tableInfoMap = tableInfo.toMap();
462 const QString
id = tableInfoMap.value( QStringLiteral(
"id" ) ).toString();
463 const QString parentLayerId = tableInfoMap.value( QStringLiteral(
"parentLayerId" ) ).toString();
464 const QString name = tableInfoMap.value( QStringLiteral(
"name" ) ).toString();
465 const QString description = tableInfoMap.value( QStringLiteral(
"description" ) ).toString();
469 if ( !tableInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
481 if ( filter !=
ServiceTypeFilter::Vector && layerInfoList.count() > 1 && serviceData.contains( QStringLiteral(
"supportedImageFormatTypes" ) ) )
483 const QString name = QStringLiteral(
"(%1)" ).arg( QObject::tr(
"All layers" ) );
484 const QString description = serviceData.value( QStringLiteral(
"Comments" ) ).toString();
489 if ( serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) ) )
491 const QString name = serviceData.value( QStringLiteral(
"name" ) ).toString();
492 const QString description = serviceData.value( QStringLiteral(
"description" ) ).toString();
504QgsArcGisAsyncQuery::QgsArcGisAsyncQuery( QObject *parent )
509QgsArcGisAsyncQuery::~QgsArcGisAsyncQuery()
512 mReply->deleteLater();
515void QgsArcGisAsyncQuery::start(
const QUrl &url,
const QString &authCfg, QByteArray *result,
bool allowCache,
const QgsHttpHeaders &headers )
518 QNetworkRequest request( url );
524 const QString error = tr(
"network request update failed for authentication config" );
525 emit failed( QStringLiteral(
"Network" ), error );
532 request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
533 request.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
536 connect( mReply, &QNetworkReply::finished,
this, &QgsArcGisAsyncQuery::handleReply );
539void QgsArcGisAsyncQuery::handleReply()
541 mReply->deleteLater();
543 if ( mReply->error() != QNetworkReply::NoError )
545 QgsDebugError( QStringLiteral(
"Network error: %1" ).arg( mReply->errorString() ) );
546 emit failed( QStringLiteral(
"Network error" ), mReply->errorString() );
551 const QVariant redirect = mReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
554 QNetworkRequest request = mReply->request();
557 request.setUrl( redirect.toUrl() );
559 connect( mReply, &QNetworkReply::finished,
this, &QgsArcGisAsyncQuery::handleReply );
563 *mResult = mReply->readAll();
572QgsArcGisAsyncParallelQuery::QgsArcGisAsyncParallelQuery(
const QString &authcfg,
const QgsHttpHeaders &requestHeaders, QObject *parent )
574 , mAuthCfg( authcfg )
575 , mRequestHeaders( requestHeaders )
579void QgsArcGisAsyncParallelQuery::start(
const QVector<QUrl> &urls, QVector<QByteArray> *results,
bool allowCache )
581 Q_ASSERT( results->size() == urls.size() );
583 mPendingRequests = mResults->size();
584 for (
int i = 0, n = urls.size(); i < n; ++i )
586 QNetworkRequest request( urls[i] );
590 mRequestHeaders.updateNetworkRequest( request );
593 const QString error = tr(
"network request update failed for authentication config" );
594 mErrors.append( error );
599 request.setAttribute( QNetworkRequest::HttpPipeliningAllowedAttribute,
true );
602 request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
603 request.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
604 request.setRawHeader(
"Connection",
"keep-alive" );
607 reply->setProperty(
"idx", i );
608 connect( reply, &QNetworkReply::finished,
this, &QgsArcGisAsyncParallelQuery::handleReply );
612void QgsArcGisAsyncParallelQuery::handleReply()
614 QNetworkReply *reply = qobject_cast<QNetworkReply *>( QObject::sender() );
615 const QVariant redirect = reply->attribute( QNetworkRequest::RedirectionTargetAttribute );
616 const int idx = reply->property(
"idx" ).toInt();
617 reply->deleteLater();
618 if ( reply->error() != QNetworkReply::NoError )
621 mErrors.append( reply->errorString() );
627 QNetworkRequest request = reply->request();
630 request.setUrl( redirect.toUrl() );
632 reply->setProperty(
"idx", idx );
633 connect( reply, &QNetworkReply::finished,
this, &QgsArcGisAsyncParallelQuery::handleReply );
638 ( *mResults )[idx] = reply->readAll();
641 if ( mPendingRequests == 0 )
643 emit finished( mErrors );
ArcGisRestServiceType
Available ArcGIS REST service types.
@ GeocodeServer
GeocodeServer.
@ Unknown
Other unknown/unsupported type.
@ GlobeServer
GlobeServer.
@ ImageServer
ImageServer.
@ FeatureServer
FeatureServer.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
WkbType
The WKB type describes the number of dimensions a geometry has.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static void visitFolderItems(const std::function< void(const QString &folderName, const QString &url)> &visitor, const QVariantMap &serviceData, const QString &baseUrl)
Calls the specified visitor function on all folder items found within the given service data.
static QgsRectangle getExtent(const QString &layerurl, const QString &whereClause, const QString &authcfg, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders())
Retrieves the extent for the features matching a whereClause.
static QVariantMap getLayerInfo(const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders())
Retrieves JSON layer info for the specified layer URL.
static QUrl parseUrl(const QUrl &url, bool *isTestEndpoint=nullptr)
Parses and processes a url.
static void addLayerItems(const std::function< void(const QString &parentLayerId, ServiceTypeFilter serviceType, Qgis::GeometryType geometryType, const QString &layerId, const QString &name, const QString &description, const QString &url, bool isParentLayer, const QString &authid, const QString &format)> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const QString &parentSupportedFormats, const ServiceTypeFilter filter=ServiceTypeFilter::AllTypes)
Calls the specified visitor function on all layer items found within the given service data.
ServiceTypeFilter
Service types.
static QList< quint32 > getObjectIdsByExtent(const QString &layerurl, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QString &authcfg, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr, const QString &whereClause=QString())
Gets a list of object IDs which fall within the specified extent.
static void visitServiceItems(const std::function< void(const QString &serviceName, const QString &url, Qgis::ArcGisRestServiceType serviceType)> &visitor, const QVariantMap &serviceData, const QString &baseUrl)
Calls the specified visitor function on all service items found within the given service data.
static QVariantMap getObjects(const QString &layerurl, const QString &authcfg, const QList< quint32 > &objectIds, const QString &crs, bool fetchGeometry, const QStringList &fetchAttributes, bool fetchM, bool fetchZ, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr)
Retrieves all matching objects from the specified layer URL.
static QVariantMap queryServiceJSON(const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr)
Performs a blocking request to a URL and returns the retrieved JSON content.
static QByteArray queryService(const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr, QString *contentType=nullptr)
Performs a blocking request to a URL and returns the retrieved data.
static QVariantMap getServiceInfo(const QString &baseurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders())
Retrieves JSON service info for the specified base URL.
static QVariantMap getObjectIds(const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), const QgsRectangle &bbox=QgsRectangle(), const QString &whereClause=QString())
Retrieves all object IDs for the specified layer URL.
static QgsCoordinateReferenceSystem convertSpatialReference(const QVariantMap &spatialReferenceMap)
Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.
static Qgis::WkbType convertGeometryType(const QString &type)
Converts an ESRI REST geometry type to a WKB type.
static Qgis::ArcGisRestServiceType serviceTypeFromString(const QString &type)
Converts a string value to a REST service type.
static QgsRectangle convertRectangle(const QVariant &value)
Converts a rectangle value to a QgsRectangle.
bool updateNetworkRequest(QNetworkRequest &request, const QString &authcfg, const QString &dataprovider=QString())
Provider call to update a QNetworkRequest with an authentication config.
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
ErrorCode get(QNetworkRequest &request, bool forceRefresh=false, QgsFeedback *feedback=nullptr)
Performs a "get" operation on the specified request.
void setAuthCfg(const QString &authCfg)
Sets the authentication config id which should be used during the request.
QString errorMessage() const
Returns the error message string, after a get(), post(), head() or put() request has been made.
@ NoError
No error was encountered.
QgsNetworkReplyContent reply() const
Returns the content of the network reply, after a get(), post(), head() or put() request has been mad...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const
Tells whether the operation has been canceled already.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...
QByteArray content() const
Returns the reply content.
QByteArray rawHeader(const QByteArray &headerName) const
Returns the content of the header with the specified headerName, or an empty QByteArray if the specif...
A rectangle specified with double values.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
bool isNull() const
Test if the rectangle is null (holding no spatial information).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
static bool isNull(const QVariant &variant)
Returns true if the specified variant should be considered a NULL value.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
#define QgsSetRequestInitiatorClass(request, _class)
#define QgsSetRequestInitiatorId(request, str)
const QgsCoordinateReferenceSystem & crs