Class: QgsHttpHeaders

Implements simple HTTP header management.

Added in version 3.24.

Methods

headers

Returns the headers as a variant map

insert

insert a key with the specific value

keys

Returns the list of all HTTP header keys.

sanitizeKey

Returns a cleansed key

setFromDomElement

Loads headers from the element

setFromMap

Loads headers from the map

setFromSettings

Loads headers from the settings

setFromUrlQuery

Loads headers from the uri

toSpacedString

Returns key/value pairs as strings separated by space

updateDomElement

Updates a DOM element by adding all the HTTP headers

updateMap

Updates a map by adding all the HTTP headers

updateNetworkRequest

Updates a request by adding all the HTTP headers

updateSettings

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

updateUrlQuery

Updates an uri by adding all the HTTP headers

class qgis.core.QgsHttpHeaders[source]

Bases: object

__init__(headers: Dict[str, Any])

Constructor from map

Parameters:

headers (Dict[str, Any])

__init__()
__init__(settings: QgsSettings, key: str | None = '')

Constructor from QgsSettings settings object and root key

Parameters:

Deprecated since version 3.30: Use a variant map settings and the default constructor instead.

__init__(key: str | None)

Constructor from default QgsSettings object and root key

Parameters:

key (Optional[str])

__init__(element: QDomElement)

Constructor from a QDomElement element

Parameters:

element (QDomElement)

__init__(a0: QgsHttpHeaders)
Parameters:

a0 (QgsHttpHeaders)

headers(self) Dict[str, Any][source]

Returns the headers as a variant map

Added in version 3.30.

Return type:

Dict[str, Any]

insert(self, key: str | None, value: Any)[source]

insert a key with the specific value

Parameters:
  • key (Optional[str]) – a key to add

  • value (Any) – a value to add for the key

keys(self) List[str]

Returns the list of all HTTP header keys.

Return type:

List[str]

sanitizeKey(self, key: str | None) str[source]

Returns a cleansed key

Parameters:

key (Optional[str]) – a key to be sanitized

Return type:

str

setFromDomElement(self, element: QDomElement)[source]

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 (QDomElement)

setFromMap(self, map: Dict[str, Any])[source]

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 (Dict[str, Any])

setFromSettings(self, settings: QgsSettings, key: str | None = '')[source]

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 (QgsSettings)

  • key (Optional[str] = '') – sub group path

setFromUrlQuery(self, uri: QUrlQuery)[source]

Loads headers from the uri

Parameters:

uri (QUrlQuery)

toSpacedString(self) str[source]

Returns key/value pairs as strings separated by space

Return type:

str

updateDomElement(self, el: QDomElement) bool[source]

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:

el (QDomElement) – DOM element

Return type:

bool

Returns:

True if the update succeed

Deprecated since version 3.42: Will be removed in QGIS 4.0.

updateMap(self, map: Dict[str, Any]) bool[source]

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)

Return type:

bool

Returns:

True if the update succeed

Parameters:

map (Dict[str, Any])

updateNetworkRequest(self, request: QNetworkRequest) bool[source]

Updates a request by adding all the HTTP headers

Return type:

bool

Returns:

True if the update succeed

Parameters:

request (QNetworkRequest)

updateSettings(self, settings: QgsSettings, key: str | None = '') bool[source]

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 (QgsSettings)

  • key (Optional[str] = '') – sub group path

Return type:

bool

Returns:

True if the update succeed

Deprecated since version 3.30: Directly use a variant setting instead.

updateUrlQuery(self, uri: QUrlQuery) bool[source]

Updates an uri by adding all the HTTP headers

Return type:

bool

Returns:

True if the update succeed

Parameters:

uri (QUrlQuery)