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

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 105 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 19 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 46 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 79 of file qgsnetworkreply.h.

◆ clear()

void QgsNetworkReplyContent::clear ( )

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

Definition at line 41 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 171 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 88 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 99 of file qgsnetworkreply.h.

◆ 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 51 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 72 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 61 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 114 of file qgsnetworkreply.h.

◆ request()

QNetworkRequest QgsNetworkReplyContent::request ( ) const
inline

Returns the original network request.

Definition at line 153 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 148 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 161 of file qgsnetworkreply.h.


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