QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsNetworkReplyContent Class Reference

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

#include <qgsnetworkreply.h>

Public Types

typedef QPair< QByteArray, QByteArray > RawHeaderPair
 

Public Member Functions

 QgsNetworkReplyContent ()=default
 Default constructor for an empty reply.
 
 QgsNetworkReplyContent (QNetworkReply *reply)
 Constructor for QgsNetworkReplyContent, populated from the specified reply.
 
QVariant attribute (QNetworkRequest::Attribute code) const
 Returns the attribute associated with the code.
 
QMap< QNetworkRequest::Attribute, QVariant > attributes () const
 Returns a list of valid attributes received in the reply.
 
void clear ()
 Clears the reply, resetting it back to a default, empty reply.
 
QByteArray content () const
 Returns the reply content.
 
QNetworkReply::NetworkError error () const
 Returns the reply's error message, or QNetworkReply::NoError if no error was encountered.
 
QString errorString () const
 Returns the error text for the reply, or an empty string if no error was encountered.
 
bool hasRawHeader (const QByteArray &headerName) const
 Returns true if the reply contains a header with the specified headerName.
 
QByteArray rawHeader (const QByteArray &headerName) const
 Returns the content of the header with the specified headerName, or an empty QByteArray if the specified header was not found in the reply.
 
QList< QByteArray > rawHeaderList () const
 Returns a list of raw header names contained within the reply.
 
const QList< RawHeaderPair > & rawHeaderPairs () const
 Returns the list of raw header pairs in the reply.
 
QNetworkRequest request () const
 Returns the original network request.
 
int requestId () const
 Returns the unique ID identifying the original request which this response was formed from.
 
void setContent (const QByteArray &content)
 Sets the reply content.
 

Static Public Member Functions

static QString extractFileNameFromContentDispositionHeader (const QString &header)
 Extracts the filename component of the content disposition header from the header.
 
static QString extractFilenameFromContentDispositionHeader (QNetworkReply *reply)
 Extracts the filename component of the content disposition header from a network reply.
 

Detailed Description

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

Since
QGIS 3.6

Definition at line 28 of file qgsnetworkreply.h.

Member Typedef Documentation

◆ RawHeaderPair

typedef QPair<QByteArray, QByteArray> QgsNetworkReplyContent::RawHeaderPair

Definition at line 92 of file qgsnetworkreply.h.

Constructor & Destructor Documentation

◆ QgsNetworkReplyContent() [1/2]

QgsNetworkReplyContent::QgsNetworkReplyContent ( )
default

Default constructor for an empty reply.

◆ QgsNetworkReplyContent() [2/2]

QgsNetworkReplyContent::QgsNetworkReplyContent ( QNetworkReply *  reply)
explicit

Constructor for QgsNetworkReplyContent, populated from the specified reply.

Definition at line 21 of file qgsnetworkreply.cpp.

Member Function Documentation

◆ attribute()

QVariant QgsNetworkReplyContent::attribute ( QNetworkRequest::Attribute  code) const

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

Definition at line 45 of file qgsnetworkreply.cpp.

◆ attributes()

QMap< QNetworkRequest::Attribute, QVariant > QgsNetworkReplyContent::attributes ( ) const
inline

Returns a list of valid attributes received in the reply.

See also
attribute()
Note
Not available in Python bindings

Definition at line 66 of file qgsnetworkreply.h.

◆ clear()

void QgsNetworkReplyContent::clear ( )

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

Definition at line 40 of file qgsnetworkreply.cpp.

◆ content()

QByteArray QgsNetworkReplyContent::content ( ) const
inline

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

Definition at line 158 of file qgsnetworkreply.h.

◆ error()

QNetworkReply::NetworkError QgsNetworkReplyContent::error ( ) const
inline

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

See also
errorString()

Definition at line 75 of file qgsnetworkreply.h.

◆ errorString()

QString QgsNetworkReplyContent::errorString ( ) const
inline

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

See also
error()

Definition at line 86 of file qgsnetworkreply.h.

◆ extractFileNameFromContentDispositionHeader()

QString QgsNetworkReplyContent::extractFileNameFromContentDispositionHeader ( const QString &  header)
static

Extracts the filename component of the content disposition header from the header.

Since
QGIS 3.28

Definition at line 89 of file qgsnetworkreply.cpp.

◆ extractFilenameFromContentDispositionHeader()

QString QgsNetworkReplyContent::extractFilenameFromContentDispositionHeader ( QNetworkReply *  reply)
static

Extracts the filename component of the content disposition header from a network reply.

Since
QGIS 3.28

Definition at line 81 of file qgsnetworkreply.cpp.

◆ hasRawHeader()

bool QgsNetworkReplyContent::hasRawHeader ( const QByteArray &  headerName) const

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

See also
rawHeaderPairs()
rawHeaderList()
rawHeader()

Definition at line 50 of file qgsnetworkreply.cpp.

◆ rawHeader()

QByteArray QgsNetworkReplyContent::rawHeader ( const QByteArray &  headerName) const

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()
hasRawHeader()
rawHeaderList()

Definition at line 71 of file qgsnetworkreply.cpp.

◆ rawHeaderList()

QList< QByteArray > QgsNetworkReplyContent::rawHeaderList ( ) const

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

See also
rawHeaderPairs()
hasRawHeader()
rawHeader()

Definition at line 60 of file qgsnetworkreply.cpp.

◆ rawHeaderPairs()

const QList< RawHeaderPair > & QgsNetworkReplyContent::rawHeaderPairs ( ) const
inline

Returns the list of raw header pairs in the reply.

See also
hasRawHeader()
rawHeaderList()
rawHeader()
Note
Not available in Python bindings

Definition at line 101 of file qgsnetworkreply.h.

◆ request()

QNetworkRequest QgsNetworkReplyContent::request ( ) const
inline

Returns the original network request.

Definition at line 140 of file qgsnetworkreply.h.

◆ requestId()

int QgsNetworkReplyContent::requestId ( ) const
inline

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

Definition at line 135 of file qgsnetworkreply.h.

◆ setContent()

void QgsNetworkReplyContent::setContent ( const QByteArray &  content)
inline

Sets the reply content.

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

See also
content()

Definition at line 148 of file qgsnetworkreply.h.


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