Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
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. | |
QHttpHeaders | headers () const |
void | setHeaders (const QHttpHeaders &headers) |
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 87 of file qabstractnetworkcache.cpp.
QNetworkCacheMetaData::QNetworkCacheMetaData | ( | const QNetworkCacheMetaData & | other | ) |
Constructs a copy of the other QNetworkCacheMetaData.
Definition at line 103 of file qabstractnetworkcache.cpp.
QNetworkCacheMetaData::~QNetworkCacheMetaData | ( | ) |
Destroys the network cache meta data.
Definition at line 95 of file qabstractnetworkcache.cpp.
QNetworkCacheMetaData::AttributesMap QNetworkCacheMetaData::attributes | ( | ) | const |
Returns all the attributes stored with this cache item.
Definition at line 292 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::attributes.
Referenced by 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 272 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::expirationDate.
Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), and QNetworkCacheMetaDataPrivate::save().
QHttpHeaders QNetworkCacheMetaData::headers | ( | ) | const |
Returns headers in form of QHttpHeaders that are set in this meta data.
Definition at line 236 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::headers.
Referenced by QCacheItem::canCompress(), QNetworkDiskCache::prepare(), QCacheItem::read(), and setHeaders().
bool QNetworkCacheMetaData::isValid | ( | ) | const |
Returns true
if this network cache meta data has attributes that have been set otherwise false.
Definition at line 150 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 256 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 111 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 130 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 214 of file qabstractnetworkcache.cpp.
References QNetworkHeadersPrivate::fromHttpToRaw(), and QNetworkCacheMetaDataPrivate::headers.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), 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 167 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::saveToDisk.
Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), and QNetworkCacheMetaDataPrivate::save().
void QNetworkCacheMetaData::setAttributes | ( | const AttributesMap & | attributes | ) |
Sets all attributes of this cache item to be the map attributes.
Definition at line 304 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 280 of file qabstractnetworkcache.cpp.
References dateTime, and QNetworkCacheMetaDataPrivate::expirationDate.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().
void QNetworkCacheMetaData::setHeaders | ( | const QHttpHeaders & | headers | ) |
Sets the headers of this network cache meta data to headers.
Definition at line 248 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::headers, and headers().
Sets the date and time when the meta data was last modified to dateTime.
Definition at line 264 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 224 of file qabstractnetworkcache.cpp.
References QNetworkHeadersPrivate::fromRawToHttp(), QNetworkCacheMetaDataPrivate::headers, and list.
Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), and QNetworkCacheMetaDataPrivate::load().
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 178 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 200 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 188 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 317 of file qabstractnetworkcache.cpp.
References out, and QNetworkCacheMetaDataPrivate::save().
|
related |
Reads a QNetworkCacheMetaData from the stream in into metaData.
Definition at line 355 of file qabstractnetworkcache.cpp.
References QNetworkCacheMetaDataPrivate::load().
|
friend |
Definition at line 67 of file qabstractnetworkcache.h.