QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
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. | |
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between threads.
Definition at line 28 of file qgsnetworkreply.h.
typedef QPair<QByteArray, QByteArray> QgsNetworkReplyContent::RawHeaderPair |
Definition at line 92 of file qgsnetworkreply.h.
|
default |
Default constructor for an empty reply.
|
explicit |
Constructor for QgsNetworkReplyContent, populated from the specified reply.
Definition at line 21 of file qgsnetworkreply.cpp.
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.
Definition at line 45 of file qgsnetworkreply.cpp.
|
inline |
Returns a list of valid attributes received in the reply.
Definition at line 66 of file qgsnetworkreply.h.
void QgsNetworkReplyContent::clear | ( | ) |
Clears the reply, resetting it back to a default, empty reply.
Definition at line 40 of file qgsnetworkreply.cpp.
|
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.
Definition at line 158 of file qgsnetworkreply.h.
|
inline |
Returns the reply's error message, or QNetworkReply::NoError if no error was encountered.
Definition at line 75 of file qgsnetworkreply.h.
|
inline |
Returns the error text for the reply, or an empty string if no error was encountered.
Definition at line 86 of file qgsnetworkreply.h.
|
static |
Extracts the filename component of the content disposition header from the header.
Definition at line 89 of file qgsnetworkreply.cpp.
|
static |
Extracts the filename component of the content disposition header from a network reply.
Definition at line 81 of file qgsnetworkreply.cpp.
bool QgsNetworkReplyContent::hasRawHeader | ( | const QByteArray & | headerName | ) | const |
Returns true
if the reply contains a header with the specified headerName.
Definition at line 50 of file qgsnetworkreply.cpp.
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.
Definition at line 71 of file qgsnetworkreply.cpp.
QList< QByteArray > QgsNetworkReplyContent::rawHeaderList | ( | ) | const |
Returns a list of raw header names contained within the reply.
Definition at line 60 of file qgsnetworkreply.cpp.
|
inline |
Returns the list of raw header pairs in the reply.
Definition at line 101 of file qgsnetworkreply.h.
|
inline |
Returns the original network request.
Definition at line 140 of file qgsnetworkreply.h.
|
inline |
Returns the unique ID identifying the original request which this response was formed from.
Definition at line 135 of file qgsnetworkreply.h.
|
inline |
Sets the reply content.
This is not done by default, as reading network reply content can only be done once.
Definition at line 148 of file qgsnetworkreply.h.