QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
QgsHttpHeaders Class Reference

Implements simple HTTP header management. More...

#include <qgshttpheaders.h>

Public Member Functions

 QgsHttpHeaders ()
 QgsHttpHeaders (const QDomElement &element)
 Constructor from a QDomElement element.
Q_DECL_DEPRECATED QgsHttpHeaders (const QgsSettings &settings, const QString &key=QString())
 Constructor from QgsSettings settings object and root key.
 QgsHttpHeaders (const QString &key)
 Constructor from default QgsSettings object and root key.
 QgsHttpHeaders (const QVariantMap &headers)
 Constructor from map.
virtual ~QgsHttpHeaders ()
 default detructor
QVariantMap headers () const
 Returns the headers as a variant map.
void insert (const QString &key, const QVariant &value)
 insert a key with the specific value
QList< QString > keys () const
 Returns the list of all HTTP header keys.
bool operator!= (const QgsHttpHeaders &other) const
QgsHttpHeadersoperator= (const QMap< QString, QVariant > &headers)
bool operator== (const QgsHttpHeaders &other) const
QVariant & operator[] (const QString &key)
const QVariant operator[] (const QString &key) const
QString sanitizeKey (const QString &key) const
 Returns a cleansed key.
void setFromDomElement (const QDomElement &element)
 Loads headers from the element.
void setFromMap (const QVariantMap &map)
 Loads headers from the map.
void setFromSettings (const QgsSettings &settings, const QString &key=QString())
 Loads headers from the settings.
void setFromUrlQuery (const QUrlQuery &uri)
 Loads headers from the uri.
QString toSpacedString () const
 Returns key/value pairs as strings separated by space.
Q_DECL_DEPRECATED bool updateDomElement (QDomElement &el) const
 Updates a DOM element by adding all the HTTP headers.
bool updateDomElement (QDomElement &el, QMap< QString, QString > &namespaceDeclarations) const
 Updates a DOM element by adding all the HTTP headers.
bool updateMap (QVariantMap &map) const
 Updates a map by adding all the HTTP headers.
bool updateNetworkRequest (QNetworkRequest &request) const
 Updates a request by adding all the HTTP headers.
Q_DECL_DEPRECATED bool updateSettings (QgsSettings &settings, const QString &key=QString()) const
 Updates the settings by adding all the http headers in the path "key/PATH_PREFIX/".
bool updateUrlQuery (QUrlQuery &uri) const
 Updates an uri by adding all the HTTP headers.

Static Public Attributes

static const QString KEY_REFERER = "referer"
 Used in settings as the referer key.
static const QString PARAM_PREFIX = "http-header:"
 Used in uri to pass headers as params.
static const QString PATH_PREFIX = "http-header/"
 Used in settings as the group name.

Detailed Description

Implements simple HTTP header management.

Since
QGIS 3.24

Definition at line 40 of file qgshttpheaders.h.

Constructor & Destructor Documentation

◆ QgsHttpHeaders() [1/5]

QgsHttpHeaders::QgsHttpHeaders ( const QVariantMap & headers)

Constructor from map.

Parameters
headers

Definition at line 40 of file qgshttpheaders.cpp.

◆ QgsHttpHeaders() [2/5]

QgsHttpHeaders::QgsHttpHeaders ( )
default

◆ QgsHttpHeaders() [3/5]

QgsHttpHeaders::QgsHttpHeaders ( const QgsSettings & settings,
const QString & key = QString() )

Constructor from QgsSettings settings object and root key.

Parameters
settings
key
Deprecated
QGIS 3.30. Use a variant map settings and the default constructor instead.

Definition at line 46 of file qgshttpheaders.cpp.

◆ QgsHttpHeaders() [4/5]

QgsHttpHeaders::QgsHttpHeaders ( const QString & key)

Constructor from default QgsSettings object and root key.

Parameters
key

Definition at line 51 of file qgshttpheaders.cpp.

◆ QgsHttpHeaders() [5/5]

QgsHttpHeaders::QgsHttpHeaders ( const QDomElement & element)

Constructor from a QDomElement element.

Parameters
element

Definition at line 56 of file qgshttpheaders.cpp.

◆ ~QgsHttpHeaders()

QgsHttpHeaders::~QgsHttpHeaders ( )
virtualdefault

default detructor

Member Function Documentation

◆ headers()

QVariantMap QgsHttpHeaders::headers ( ) const
inline

Returns the headers as a variant map.

Since
QGIS 3.30

Definition at line 92 of file qgshttpheaders.h.

◆ insert()

void QgsHttpHeaders::insert ( const QString & key,
const QVariant & value )

insert a key with the specific value

Parameters
keya key to add
valuea value to add for the key

Definition at line 291 of file qgshttpheaders.cpp.

◆ keys()

QList< QString > QgsHttpHeaders::keys ( ) const

Returns the list of all HTTP header keys.

Definition at line 285 of file qgshttpheaders.cpp.

◆ operator!=()

bool QgsHttpHeaders::operator!= ( const QgsHttpHeaders & other) const

Definition at line 307 of file qgshttpheaders.cpp.

◆ operator=()

QgsHttpHeaders & QgsHttpHeaders::operator= ( const QMap< QString, QVariant > & headers)

Definition at line 279 of file qgshttpheaders.cpp.

◆ operator==()

bool QgsHttpHeaders::operator== ( const QgsHttpHeaders & other) const

Definition at line 302 of file qgshttpheaders.cpp.

◆ operator[]() [1/2]

QVariant & QgsHttpHeaders::operator[] ( const QString & key)
Parameters
keyhttp header key name
Returns
http header value

Definition at line 269 of file qgshttpheaders.cpp.

◆ operator[]() [2/2]

const QVariant QgsHttpHeaders::operator[] ( const QString & key) const
Parameters
keyhttp header key name
Returns
http header value

Definition at line 274 of file qgshttpheaders.cpp.

◆ sanitizeKey()

QString QgsHttpHeaders::sanitizeKey ( const QString & key) const

Returns a cleansed key.

Parameters
keya key to be sanitized

Definition at line 262 of file qgshttpheaders.cpp.

◆ setFromDomElement()

void QgsHttpHeaders::setFromDomElement ( const QDomElement & element)

Loads headers from the element.

key KEY_REFERER will be read from attribute "KEY_PREFIX+KEY_REFERER" and attribute "KEY_REFERER" (for backward compatibility)

Parameters
element

Definition at line 223 of file qgshttpheaders.cpp.

◆ setFromMap()

void QgsHttpHeaders::setFromMap ( const QVariantMap & map)

Loads headers from the map.

key KEY_REFERER will be read from key "KEY_PREFIX+KEY_REFERER" and key "KEY_REFERER" (for backward compatibility)

Parameters
map

Definition at line 204 of file qgshttpheaders.cpp.

◆ setFromSettings()

void QgsHttpHeaders::setFromSettings ( const QgsSettings & settings,
const QString & key = QString() )

Loads headers from the settings.

key KEY_REFERER will be read at path "key/PATH_PREFIX/KEY_REFERER" and path "key/KEY_REFERER" (for backward compatibility)

Parameters
settings
keysub group path

Definition at line 150 of file qgshttpheaders.cpp.

◆ setFromUrlQuery()

void QgsHttpHeaders::setFromUrlQuery ( const QUrlQuery & uri)

Loads headers from the uri.

Parameters
uri

Definition at line 186 of file qgshttpheaders.cpp.

◆ toSpacedString()

QString QgsHttpHeaders::toSpacedString ( ) const

Returns key/value pairs as strings separated by space.

Definition at line 245 of file qgshttpheaders.cpp.

◆ updateDomElement() [1/2]

bool QgsHttpHeaders::updateDomElement ( QDomElement & el) const

Updates a DOM element by adding all the HTTP headers.

KEY_REFERER value will be available at attribute "KEY_PREFIX+KEY_REFERER" and attribute "KEY_REFERER" (for backward compatibility)

Parameters
elDOM element
Returns
true if the update succeed
Deprecated
QGIS 3.42. Will be removed in QGIS 4.0.

Definition at line 124 of file qgshttpheaders.cpp.

◆ updateDomElement() [2/2]

bool QgsHttpHeaders::updateDomElement ( QDomElement & el,
QMap< QString, QString > & namespaceDeclarations ) const

Updates a DOM element by adding all the HTTP headers.

KEY_REFERER value will be available at attribute "KEY_PREFIX+KEY_REFERER" and attribute "KEY_REFERER" (for backward compatibility)

Parameters
elDOM element
[out]namespaceDeclarationsMap of (prefix, URI) tuples for namespaces used by el.
Returns
true if the update succeed

Definition at line 130 of file qgshttpheaders.cpp.

◆ updateMap()

bool QgsHttpHeaders::updateMap ( QVariantMap & map) const

Updates a map by adding all the HTTP headers.

KEY_REFERER value will be available at key "KEY_PREFIX+KEY_REFERER" and key "KEY_REFERER" (for backward compatibility)

Returns
true if the update succeed

Definition at line 109 of file qgshttpheaders.cpp.

◆ updateNetworkRequest()

bool QgsHttpHeaders::updateNetworkRequest ( QNetworkRequest & request) const

Updates a request by adding all the HTTP headers.

Returns
true if the update succeed

Definition at line 63 of file qgshttpheaders.cpp.

◆ updateSettings()

bool QgsHttpHeaders::updateSettings ( QgsSettings & settings,
const QString & key = QString() ) const

Updates the settings by adding all the http headers in the path "key/PATH_PREFIX/".

KEY_REFERER value will be available at path "key/PATH_PREFIX/KEY_REFERER" and path "key/KEY_REFERER" (for backward compatibility)

Parameters
settings
keysub group path
Returns
true if the update succeed
Deprecated
QGIS 3.30. Directly use a variant setting instead.

Definition at line 81 of file qgshttpheaders.cpp.

◆ updateUrlQuery()

bool QgsHttpHeaders::updateUrlQuery ( QUrlQuery & uri) const

Updates an uri by adding all the HTTP headers.

Returns
true if the update succeed

Definition at line 72 of file qgshttpheaders.cpp.

Member Data Documentation

◆ KEY_REFERER

const QString QgsHttpHeaders::KEY_REFERER = "referer"
static

Used in settings as the referer key.

Definition at line 50 of file qgshttpheaders.h.

◆ PARAM_PREFIX

const QString QgsHttpHeaders::PARAM_PREFIX = "http-header:"
static

Used in uri to pass headers as params.

Definition at line 53 of file qgshttpheaders.h.

◆ PATH_PREFIX

const QString QgsHttpHeaders::PATH_PREFIX = "http-header/"
static

Used in settings as the group name.

Definition at line 47 of file qgshttpheaders.h.


The documentation for this class was generated from the following files: