![]() |
Qt 6.x
The Qt SDK
|
The QNetworkCacheMetaData class provides cache information. More...
#include <qabstractnetworkcache.h>
Public Types | |
typedef QPair< QByteArray, QByteArray > | RawHeader |
Synonym for QPair<QByteArray, QByteArray> | |
typedef QList< RawHeader > | RawHeaderList |
Synonym for QList<RawHeader> | |
typedef QHash< QNetworkRequest::Attribute, QVariant > | AttributesMap |
Synonym for QHash<QNetworkRequest::Attribute, QVariant> | |
Public Member Functions | |
QNetworkCacheMetaData () | |
Constructs an invalid network cache meta data. | |
QNetworkCacheMetaData (const QNetworkCacheMetaData &other) | |
Constructs a copy of the other QNetworkCacheMetaData. | |
~QNetworkCacheMetaData () | |
Destroys the network cache meta data. | |
QNetworkCacheMetaData & | operator= (QNetworkCacheMetaData &&other) noexcept |
QNetworkCacheMetaData & | operator= (const QNetworkCacheMetaData &other) |
Makes a copy of the other QNetworkCacheMetaData and returns a reference to the copy. | |
void | swap (QNetworkCacheMetaData &other) noexcept |
bool | operator== (const QNetworkCacheMetaData &other) const |
Returns true if this meta data is equal to the other meta data; otherwise returns false . | |
bool | operator!= (const QNetworkCacheMetaData &other) const |
Returns true if this meta data is not equal to the other meta data; otherwise returns false . | |
bool | isValid () const |
Returns true if this network cache meta data has attributes that have been set otherwise false. | |
QUrl | url () const |
Returns the URL this network cache meta data is referring to. | |
void | setUrl (const QUrl &url) |
Sets the URL this network cache meta data to be url. | |
RawHeaderList | rawHeaders () const |
Returns a list of all raw headers that are set in this meta data. | |
void | setRawHeaders (const RawHeaderList &headers) |
Sets the raw headers to list. | |
QDateTime | lastModified () const |
Returns the date and time when the meta data was last modified. | |
void | setLastModified (const QDateTime &dateTime) |
Sets the date and time when the meta data was last modified to dateTime. | |
QDateTime | expirationDate () const |
Returns the date and time when the meta data expires. | |
void | setExpirationDate (const QDateTime &dateTime) |
Sets the date and time when the meta data expires to dateTime. | |
bool | saveToDisk () const |
Returns is this cache should be allowed to be stored on disk. | |
void | setSaveToDisk (bool allow) |
Sets whether this network cache meta data and associated content should be allowed to be stored on disk to allow. | |
AttributesMap | attributes () const |
void | setAttributes (const AttributesMap &attributes) |
Friends | |
class | QNetworkCacheMetaDataPrivate |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &out, const QNetworkCacheMetaData &metaData) |
QDataStream & | operator>> (QDataStream &in, QNetworkCacheMetaData &metaData) |
The QNetworkCacheMetaData class provides cache information.
\inmodule QtNetwork
QNetworkCacheMetaData provides information about a cache file including the url, when it was last modified, when the cache file was created, headers for file and if the file should be saved onto a disk.
Definition at line 21 of file qabstractnetworkcache.h.
Synonym for QHash<QNetworkRequest::Attribute, QVariant>
Definition at line 27 of file qabstractnetworkcache.h.
Synonym for QPair<QByteArray, QByteArray>
Definition at line 25 of file qabstractnetworkcache.h.
Synonym for QList<RawHeader>
Definition at line 26 of file qabstractnetworkcache.h.
QNetworkCacheMetaData::QNetworkCacheMetaData | ( | ) |
Constructs an invalid network cache meta data.
Definition at line 85 of file qabstractnetworkcache.cpp.
QNetworkCacheMetaData::QNetworkCacheMetaData | ( | const QNetworkCacheMetaData & | other | ) |
Constructs a copy of the other QNetworkCacheMetaData.
Definition at line 101 of file qabstractnetworkcache.cpp.
QNetworkCacheMetaData::~QNetworkCacheMetaData | ( | ) |
Destroys the network cache meta data.
Definition at line 93 of file qabstractnetworkcache.cpp.
QNetworkCacheMetaData::AttributesMap QNetworkCacheMetaData::attributes | ( | ) | const |
Returns all the attributes stored with this cache item.
Definition at line 266 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::attributes.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), QNetworkReplyImplPrivate::initCacheSaveDevice(), QNetworkCacheMetaDataPrivate::save(), QNetworkReplyHttpImplPrivate::sendCacheContents(), and setAttributes().
QDateTime QNetworkCacheMetaData::expirationDate | ( | ) | const |
Returns the date and time when the meta data expires.
Definition at line 246 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::expirationDate.
Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), and QNetworkCacheMetaDataPrivate::save().
bool QNetworkCacheMetaData::isValid | ( | ) | const |
Returns true
if this network cache meta data has attributes that have been set otherwise false.
Definition at line 148 of file qabstractnetworkcache.cpp.
Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QCacheItem::read(), and QNetworkReplyHttpImplPrivate::sendCacheContents().
QDateTime QNetworkCacheMetaData::lastModified | ( | ) | const |
Returns the date and time when the meta data was last modified.
Definition at line 230 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::lastModified.
Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), and QNetworkCacheMetaDataPrivate::save().
|
inline |
Returns true
if this meta data is not equal to the other meta data; otherwise returns false
.
Definition at line 40 of file qabstractnetworkcache.h.
References other().
QNetworkCacheMetaData & QNetworkCacheMetaData::operator= | ( | const QNetworkCacheMetaData & | other | ) |
Makes a copy of the other QNetworkCacheMetaData and returns a reference to the copy.
Definition at line 109 of file qabstractnetworkcache.cpp.
References other().
|
inlinenoexcept |
Definition at line 33 of file qabstractnetworkcache.h.
References other(), and swap().
bool QNetworkCacheMetaData::operator== | ( | const QNetworkCacheMetaData & | other | ) | const |
Returns true
if this meta data is equal to the other meta data; otherwise returns false
.
Definition at line 128 of file qabstractnetworkcache.cpp.
References other().
QNetworkCacheMetaData::RawHeaderList QNetworkCacheMetaData::rawHeaders | ( | ) | const |
Returns a list of all raw headers that are set in this meta data.
The list is in the same order that the headers were set.
Definition at line 212 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::headers.
Referenced by QCacheItem::canCompress(), QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QCacheItem::read(), QNetworkReplyHttpImplPrivate::replyDownloadMetaData(), QNetworkCacheMetaDataPrivate::save(), and QNetworkReplyHttpImplPrivate::sendCacheContents().
bool QNetworkCacheMetaData::saveToDisk | ( | ) | const |
Returns is this cache should be allowed to be stored on disk.
Some cache implementations can keep these cache items in memory for performance reasons, but for security reasons they should not be written to disk.
Specifically with http, documents with Cache-control set to no-store or any https document that doesn't have "Cache-control: public" set will set the saveToDisk to false.
Definition at line 165 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::saveToDisk.
Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QNetworkCacheMetaDataPrivate::save(), and QNetworkDiskCachePrivate::storeItem().
void QNetworkCacheMetaData::setAttributes | ( | const AttributesMap & | attributes | ) |
Sets all attributes of this cache item to be the map attributes.
Definition at line 278 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::attributes, and attributes().
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), and QNetworkReplyImplPrivate::initCacheSaveDevice().
Sets the date and time when the meta data expires to dateTime.
Definition at line 254 of file qabstractnetworkcache.cpp.
References dateTime, and QNetworkCacheMetaDataPrivate::expirationDate.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().
Sets the date and time when the meta data was last modified to dateTime.
Definition at line 238 of file qabstractnetworkcache.cpp.
References dateTime, and QNetworkCacheMetaDataPrivate::lastModified.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().
void QNetworkCacheMetaData::setRawHeaders | ( | const RawHeaderList & | list | ) |
Sets the raw headers to list.
Definition at line 222 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::headers, and list.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().
void QNetworkCacheMetaData::setSaveToDisk | ( | bool | allow | ) |
Sets whether this network cache meta data and associated content should be allowed to be stored on disk to allow.
Definition at line 176 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::saveToDisk.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().
Sets the URL this network cache meta data to be url.
The password and fragment are removed from the url.
Definition at line 198 of file qabstractnetworkcache.cpp.
References QSharedDataPointer< T >::data(), QNetworkCacheMetaDataPrivate::url, url(), and QUrl::url().
Referenced by QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), and QNetworkReplyImplPrivate::initCacheSaveDevice().
|
inlinenoexcept |
Swaps this metadata instance with other. This function is very fast and never fails.
Definition at line 36 of file qabstractnetworkcache.h.
QUrl QNetworkCacheMetaData::url | ( | ) | const |
Returns the URL this network cache meta data is referring to.
Definition at line 186 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::url.
Referenced by QNetworkDiskCache::prepare(), QCacheItem::read(), QNetworkCacheMetaDataPrivate::save(), setUrl(), QNetworkDiskCachePrivate::storeItem(), and QNetworkDiskCache::updateMetaData().
|
related |
Writes metaData to the out stream.
Definition at line 291 of file qabstractnetworkcache.cpp.
References out, and QNetworkCacheMetaDataPrivate::save().
|
related |
Reads a QNetworkCacheMetaData from the stream in into metaData.
Definition at line 329 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::load().
|
friend |
Definition at line 64 of file qabstractnetworkcache.h.