QGIS API Documentation 3.29.0-Master (006c3c0232)
qgshttpheaders.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshttpheaders.h
3 This class implements simple http header management.
4
5 -------------------
6 begin : 2021-09-09
7 copyright : (C) 2021 B. De Mezzo
8 email : benoit dot de dot mezzo at oslandia dot com
9
10***************************************************************************/
11
12/***************************************************************************
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 ***************************************************************************/
20
21#ifndef QGSHTTPHEADERS_H
22#define QGSHTTPHEADERS_H
23
24#include <QMap>
25#include "qgis_core.h"
26#include "qgis_sip.h"
27#include "qgssettingsentry.h"
28
29class QNetworkRequest;
30class QUrlQuery;
31class QDomElement;
32
38class CORE_EXPORT QgsHttpHeaders
39{
40 public:
41
42#ifndef SIP_RUN
43
45 static const QString PATH_PREFIX;
46
48 static const QString KEY_REFERER;
49
51 static const QString PARAM_PREFIX;
52
53#endif
54
59 QgsHttpHeaders( const QMap<QString, QVariant> &headers );
60
65
71 QgsHttpHeaders( const QgsSettings &settings, const QString &key = QString() );
72
77 QgsHttpHeaders( const QString &key );
78
83 QgsHttpHeaders( const QDomElement &element );
84
86 virtual ~QgsHttpHeaders();
87
97 bool updateSettings( QgsSettings &settings, const QString &key = QString() ) const;
98
103 bool updateNetworkRequest( QNetworkRequest &request ) const;
104
109 bool updateUrlQuery( QUrlQuery &uri ) const;
110
118 bool updateMap( QVariantMap &map ) const;
119
127 bool updateDomElement( QDomElement &el ) const;
128
137 void setFromSettings( const QgsSettings &settings, const QString &key = QString() );
138
143 void setFromUrlQuery( const QUrlQuery &uri );
144
152 void setFromMap( const QVariantMap &map );
153
161 void setFromDomElement( const QDomElement &element );
162
167 QString sanitizeKey( const QString &key ) const;
168
173 QVariant &operator[]( const QString &key );
174
175 QgsHttpHeaders &operator = ( const QMap<QString, QVariant> &headers ) SIP_SKIP;
176
180 QList<QString> keys() const;
181
183 QString toSpacedString() const;
184
185#ifndef SIP_RUN
186
191 const QVariant operator[]( const QString &key ) const;
192#endif
193
194 private:
195 QMap<QString, QVariant> mHeaders;
196};
197
198#endif // QGSHTTPHEADERS_H
This class implements simple http header management.
static const QString PARAM_PREFIX
Used in uri to pass headers as params.
static const QString KEY_REFERER
Used in settings as the referer key.
QgsHttpHeaders()
default constructor
static const QString PATH_PREFIX
Used in settings as the group name.
virtual ~QgsHttpHeaders()
default detructor
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
#define SIP_SKIP
Definition: qgis_sip.h:126