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

HTTP network content fetcher. More...

#include <qgsnetworkcontentfetcher.h>

Inheritance diagram for QgsNetworkContentFetcher:

Signals

void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 Emitted when data is received.
void errorOccurred (QNetworkReply::NetworkError code, const QString &errorMsg)
 Emitted when an error with code error occurred while processing the request errorMsg is a textual description of the error.
void finished ()
 Emitted when content has loaded.

Public Member Functions

 QgsNetworkContentFetcher ()=default
 ~QgsNetworkContentFetcher () override
void cancel ()
 Cancels any ongoing request.
QString contentAsString () const
 Returns the fetched content as a string.
QString contentDispositionFilename () const
 Returns the associated filename from the reply's content disposition header, if present.
void fetchContent (const QNetworkRequest &request, const QString &authcfg=QString())
 Fetches content using a network request and handles redirects.
void fetchContent (const QUrl &url, const QString &authcfg=QString())
 Fetches content from a remote URL and handles redirects.
QNetworkReply * reply ()
 Returns a reference to the network reply.
bool wasCanceled () const
 Returns true if the fetching was canceled.

Detailed Description

HTTP network content fetcher.

A simple method for fetching remote HTTP content and converting the content to standard formats.

URL redirects are automatically handled.

See also
QgsNetworkContentFetcherTask

Definition at line 41 of file qgsnetworkcontentfetcher.h.

Constructor & Destructor Documentation

◆ QgsNetworkContentFetcher()

QgsNetworkContentFetcher::QgsNetworkContentFetcher ( )
default

◆ ~QgsNetworkContentFetcher()

QgsNetworkContentFetcher::~QgsNetworkContentFetcher ( )
override

Definition at line 33 of file qgsnetworkcontentfetcher.cpp.

Member Function Documentation

◆ cancel()

void QgsNetworkContentFetcher::cancel ( )

Cancels any ongoing request.

Since
QGIS 3.2

Definition at line 121 of file qgsnetworkcontentfetcher.cpp.

◆ contentAsString()

QString QgsNetworkContentFetcher::contentAsString ( ) const

Returns the fetched content as a string.

Returns
string containing network content

Definition at line 107 of file qgsnetworkcontentfetcher.cpp.

◆ contentDispositionFilename()

QString QgsNetworkContentFetcher::contentDispositionFilename ( ) const

Returns the associated filename from the reply's content disposition header, if present.

Since
QGIS 3.28

Definition at line 102 of file qgsnetworkcontentfetcher.cpp.

◆ downloadProgress

void QgsNetworkContentFetcher::downloadProgress ( qint64 bytesReceived,
qint64 bytesTotal )
signal

Emitted when data is received.

Since
QGIS 3.2

◆ errorOccurred

void QgsNetworkContentFetcher::errorOccurred ( QNetworkReply::NetworkError code,
const QString & errorMsg )
signal

Emitted when an error with code error occurred while processing the request errorMsg is a textual description of the error.

Since
QGIS 3.22

◆ fetchContent() [1/2]

void QgsNetworkContentFetcher::fetchContent ( const QNetworkRequest & request,
const QString & authcfg = QString() )

Fetches content using a network request and handles redirects.

The finished() signal will be emitted when content has been fetched.

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

Since
QGIS 3.2

Definition at line 51 of file qgsnetworkcontentfetcher.cpp.

◆ fetchContent() [2/2]

void QgsNetworkContentFetcher::fetchContent ( const QUrl & url,
const QString & authcfg = QString() )

Fetches content from a remote URL and handles redirects.

The finished() signal will be emitted when content has been fetched.

Parameters
urlURL to fetch
authcfgoptional authentication configuration

Definition at line 43 of file qgsnetworkcontentfetcher.cpp.

◆ finished

void QgsNetworkContentFetcher::finished ( )
signal

Emitted when content has loaded.

◆ reply()

QNetworkReply * QgsNetworkContentFetcher::reply ( )

Returns a reference to the network reply.

Returns
QNetworkReply for fetched URL content

Definition at line 92 of file qgsnetworkcontentfetcher.cpp.

◆ wasCanceled()

bool QgsNetworkContentFetcher::wasCanceled ( ) const

Returns true if the fetching was canceled.

Since
QGIS 3.10

Definition at line 134 of file qgsnetworkcontentfetcher.cpp.


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