Class: QgsNetworkReplyContent

class qgis.core.QgsNetworkReplyContent

Bases: sip.wrapper

Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between threads.

New in version 3.6.

QgsNetworkReplyContent() Default constructor for an empty reply.

QgsNetworkReplyContent(reply: QNetworkReply) Constructor for QgsNetworkReplyContent, populated from the specified reply.

QgsNetworkReplyContent(QgsNetworkReplyContent)

Methods

attribute

Returns the attribute associated with the code.

clear

Clears the reply, resetting it back to a default, empty reply.

content

Returns the reply content.

error

Returns the reply’s error message, or QNetworkReply.NoError if no error was encountered.

errorString

Returns the error text for the reply, or an empty string if no error was encountered.

hasRawHeader

Returns True if the reply contains a header with the specified headerName.

rawHeader

Returns the content of the header with the specified headerName, or an empty QByteArray if the specified header was not found in the reply.

rawHeaderList

Returns a list of raw header names contained within the reply.

request

Returns the original network request.

requestId

Returns the unique ID identifying the original request which this response was formed from.

setContent

Sets the reply content.

attribute(self, code: QNetworkRequest.Attribute)Any

Returns the attribute associated with the code. If the attribute has not been set, it returns an invalid QVariant.

You can expect the default values listed in QNetworkRequest.Attribute to be applied to the values returned by this function.

See also

attributes()

Parameters

code (QNetworkRequest.Attribute) –

Return type

Any

clear(self)

Clears the reply, resetting it back to a default, empty reply.

content(self)QByteArray

Returns the reply content. This is not available by default, as reading network reply content can only be done once.

Blocking network requests (see QgsBlockingNetworkRequest) will automatically populate this content.

See also

setContent()

Return type

QByteArray

error(self)QNetworkReply.NetworkError

Returns the reply’s error message, or QNetworkReply.NoError if no error was encountered.

See also

errorString()

Return type

QNetworkReply.NetworkError

errorString(self)str

Returns the error text for the reply, or an empty string if no error was encountered.

See also

error()

Return type

str

hasRawHeader(self, headerName: Union[QByteArray, bytes, bytearray])bool

Returns True if the reply contains a header with the specified headerName.

See also

rawHeaderPairs()

See also

rawHeaderList()

See also

rawHeader()

Parameters

headerName (Union[QByteArray) –

Return type

bool

rawHeader(self, headerName: Union[QByteArray, bytes, bytearray])QByteArray

Returns the content of the header with the specified headerName, or an empty QByteArray if the specified header was not found in the reply.

See also

rawHeaderPairs()

See also

hasRawHeader()

See also

rawHeaderList()

Parameters

headerName (Union[QByteArray) –

Return type

QByteArray

rawHeaderList(self)List[QByteArray]

Returns a list of raw header names contained within the reply.

See also

rawHeaderPairs()

See also

hasRawHeader()

See also

rawHeader()

Return type

List[QByteArray]

request(self)QNetworkRequest

Returns the original network request.

Return type

QNetworkRequest

requestId(self)int

Returns the unique ID identifying the original request which this response was formed from.

Return type

int

setContent(self, content: Union[QByteArray, bytes, bytearray])

Sets the reply content. This is not done by default, as reading network reply content can only be done once.

See also

content()

Parameters

content (Union[QByteArray) –