Class: QgsNetworkContentFetcherTask

class qgis.core.QgsNetworkContentFetcherTask(url: QUrl, authcfg: str = '')

Bases: qgis._core.QgsTask

Constructor for a QgsNetworkContentFetcherTask which fetches the specified url.

Optionally, authentication configuration can be set via the authcfg argument.

QgsNetworkContentFetcherTask(request: QNetworkRequest, authcfg: str = ‘’) Constructor for a QgsNetworkContentFetcherTask which fetches the specified network request.

Optionally, authentication configuration can be set via the authcfg argument.

Handles HTTP network content fetching in a background task.

Provides a simple method for fetching remote HTTP content in a QgsTask. Url redirects are automatically handled.

After constructing a QgsNetworkContentFetcherTask, callers should connect to the QgsNetworkContentFetcherTask.fetched signal. They can then safely access the network reply() from the connected slot without danger of the task being first removed by the QgsTaskManager.

New in version 3.2: Enums

Methods

cancel

childEvent

connectNotify

contentAsString

Returns the fetched content as a string

customEvent

disconnectNotify

finished

isCanceled

isSignalConnected

receivers

reply

Returns the network reply.

run

sender

senderSignalIndex

setProgress

timerEvent

Signals

fetched

Emitted when the network content has been fetched, regardless of whether the fetch was successful or not.

Attributes

cancel(self)
childEvent()
connectNotify()
contentAsString(self) → str

Returns the fetched content as a string

Warning

This should only be accessed from a slot connected directly to the QgsNetworkContentFetcherTask.fetched() signal.

New in version 3.10.

customEvent()
disconnectNotify()
fetched

Emitted when the network content has been fetched, regardless of whether the fetch was successful or not.

Users of QgsNetworkContentFetcherTask should connect to this signal, and from the associated slot they can then safely access the network reply() without danger of the task being first removed by the QgsTaskManager. [signal]

finished()
isCanceled()
isSignalConnected()
receivers()
reply(self) → QNetworkReply

Returns the network reply. Ownership is not transferred.

May return None if the request has not yet completed.

Warning

This should only be accessed from a slot connected directly to the QgsNetworkContentFetcherTask.fetched() signal.

run(self) → bool
sender()
senderSignalIndex()
setProgress()
timerEvent()