QGIS API Documentation  3.25.0-Master (10b47c2603)
qgscplhttpfetchoverrider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscplhttpfetchoverrider.h
3  --------------------------
4  begin : September 2020
5  copyright : (C) 2020 by Even Rouault
6  email : even.rouault at spatialys.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSCPLHTTPFETCHOVERRIDER_H
17 #define QGSCPLHTTPFETCHOVERRIDER_H
18 
19 #define SIP_NO_FILE
20 
21 #include <QNetworkRequest>
22 #include <QString>
23 #include "qgsnetworkaccessmanager.h" // for QgsSetRequestInitiatorClass
24 
25 #include "cpl_http.h"
26 #include "gdal.h"
27 
28 class QgsFeedback;
29 
30 #ifndef SIP_RUN
31 #define QgsSetCPLHTTPFetchOverriderInitiatorClass(overrider, _class) QgsSetRequestInitiatorClass(overrider, _class)
32 #endif
33 
45 {
46  public:
48  explicit QgsCPLHTTPFetchOverrider( const QString &authCfg = QString(), QgsFeedback *feedback = nullptr );
49 
52 
54  void setAttribute( QNetworkRequest::Attribute code, const QVariant &value );
55 
56  private:
57 
58 #if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,2,0)
59  static CPLHTTPResult *callback( const char *pszURL,
60  CSLConstList papszOptions,
61  GDALProgressFunc pfnProgress,
62  void *pProgressArg,
63  CPLHTTPFetchWriteFunc pfnWrite,
64  void *pWriteArg,
65  void *pUserData );
66 #endif
67 
68  QString mAuthCfg;
69 
70  QgsFeedback *mFeedback = nullptr;
71 
72  std::map<QNetworkRequest::Attribute, QVariant> mAttributes;
73 };
74 
75 #endif // QGSCPLHTTPFETCHOVERRIDER_H
Utility class to redirect GDAL's CPL HTTP calls through QgsBlockingNetworkRequest.
QgsCPLHTTPFetchOverrider(const QString &authCfg=QString(), QgsFeedback *feedback=nullptr)
Installs the redirection for the current thread.
void setAttribute(QNetworkRequest::Attribute code, const QVariant &value)
Define attribute that must be forwarded to the actual QNetworkRequest.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45