Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QNetworkCacheMetaData Class Reference

The QNetworkCacheMetaData class provides cache information. More...

#include <qabstractnetworkcache.h>

+ Collaboration diagram for QNetworkCacheMetaData:

Public Types

typedef QPair< QByteArray, QByteArrayRawHeader
 Synonym for QPair<QByteArray, QByteArray>
 
typedef QList< RawHeaderRawHeaderList
 Synonym for QList<RawHeader>
 
typedef QHash< QNetworkRequest::Attribute, QVariantAttributesMap
 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.
 
QNetworkCacheMetaDataoperator= (QNetworkCacheMetaData &&other) noexcept
 
QNetworkCacheMetaDataoperator= (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.)

QDataStreamoperator<< (QDataStream &out, const QNetworkCacheMetaData &metaData)
 
QDataStreamoperator>> (QDataStream &in, QNetworkCacheMetaData &metaData)
 

Detailed Description

The QNetworkCacheMetaData class provides cache information.

Since
4.5

\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.

See also
QAbstractNetworkCache

Definition at line 21 of file qabstractnetworkcache.h.

Member Typedef Documentation

◆ AttributesMap

◆ RawHeader

Synonym for QPair<QByteArray, QByteArray>

Definition at line 25 of file qabstractnetworkcache.h.

◆ RawHeaderList

Constructor & Destructor Documentation

◆ QNetworkCacheMetaData() [1/2]

QNetworkCacheMetaData::QNetworkCacheMetaData ( )

Constructs an invalid network cache meta data.

See also
isValid()

Definition at line 85 of file qabstractnetworkcache.cpp.

◆ QNetworkCacheMetaData() [2/2]

QNetworkCacheMetaData::QNetworkCacheMetaData ( const QNetworkCacheMetaData other)

Constructs a copy of the other QNetworkCacheMetaData.

Definition at line 101 of file qabstractnetworkcache.cpp.

◆ ~QNetworkCacheMetaData()

QNetworkCacheMetaData::~QNetworkCacheMetaData ( )

Destroys the network cache meta data.

Definition at line 93 of file qabstractnetworkcache.cpp.

Member Function Documentation

◆ attributes()

QNetworkCacheMetaData::AttributesMap QNetworkCacheMetaData::attributes ( ) const
Since
4.6

Returns all the attributes stored with this cache item.

See also
setAttributes(), QNetworkRequest::Attribute

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

+ Here is the caller graph for this function:

◆ expirationDate()

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

+ Here is the caller graph for this function:

◆ isValid()

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

+ Here is the caller graph for this function:

◆ lastModified()

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

+ Here is the caller graph for this function:

◆ operator!=()

bool QNetworkCacheMetaData::operator!= ( const QNetworkCacheMetaData other) const
inline

Returns true if this meta data is not equal to the other meta data; otherwise returns false.

See also
operator==()

Definition at line 40 of file qabstractnetworkcache.h.

References other().

+ Here is the call graph for this function:

◆ operator=() [1/2]

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

+ Here is the call graph for this function:

◆ operator=() [2/2]

QNetworkCacheMetaData & QNetworkCacheMetaData::operator= ( QNetworkCacheMetaData &&  other)
inlinenoexcept

Definition at line 33 of file qabstractnetworkcache.h.

References other(), and swap().

+ Here is the call graph for this function:

◆ operator==()

bool QNetworkCacheMetaData::operator== ( const QNetworkCacheMetaData other) const

Returns true if this meta data is equal to the other meta data; otherwise returns false.

See also
operator!=()

Definition at line 128 of file qabstractnetworkcache.cpp.

References other().

+ Here is the call graph for this function:

◆ rawHeaders()

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.

See also
setRawHeaders()

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

+ Here is the caller graph for this function:

◆ saveToDisk()

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.

See also
setSaveToDisk()

Definition at line 165 of file qabstractnetworkcache.cpp.

References QNetworkCacheMetaDataPrivate::saveToDisk.

Referenced by QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QNetworkCacheMetaDataPrivate::save(), and QNetworkDiskCachePrivate::storeItem().

+ Here is the caller graph for this function:

◆ setAttributes()

void QNetworkCacheMetaData::setAttributes ( const AttributesMap attributes)
Since
4.6

Sets all attributes of this cache item to be the map attributes.

See also
attributes(), QNetworkRequest::setAttribute()

Definition at line 278 of file qabstractnetworkcache.cpp.

References QNetworkCacheMetaDataPrivate::attributes, and attributes().

Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), and QNetworkReplyImplPrivate::initCacheSaveDevice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setExpirationDate()

void QNetworkCacheMetaData::setExpirationDate ( const QDateTime dateTime)

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

+ Here is the caller graph for this function:

◆ setLastModified()

void QNetworkCacheMetaData::setLastModified ( const QDateTime dateTime)

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

+ Here is the caller graph for this function:

◆ setRawHeaders()

void QNetworkCacheMetaData::setRawHeaders ( const RawHeaderList list)

Sets the raw headers to list.

See also
rawHeaders()

Definition at line 222 of file qabstractnetworkcache.cpp.

References QNetworkCacheMetaDataPrivate::headers, and list.

Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().

+ Here is the caller graph for this function:

◆ setSaveToDisk()

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.

See also
saveToDisk()

Definition at line 176 of file qabstractnetworkcache.cpp.

References QNetworkCacheMetaDataPrivate::saveToDisk.

Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData().

+ Here is the caller graph for this function:

◆ setUrl()

void QNetworkCacheMetaData::setUrl ( const QUrl url)

Sets the URL this network cache meta data to be url.

The password and fragment are removed from the url.

See also
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QNetworkCacheMetaData::swap ( QNetworkCacheMetaData other)
inlinenoexcept
Since
5.0

Swaps this metadata instance with other. This function is very fast and never fails.

Definition at line 36 of file qabstractnetworkcache.h.

References d, and other().

+ Here is the call graph for this function:

◆ url()

QUrl QNetworkCacheMetaData::url ( ) const

Returns the URL this network cache meta data is referring to.

See also
setUrl()

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

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<<()

QDataStream & operator<< ( QDataStream out,
const QNetworkCacheMetaData metaData 
)
related
Since
4.5

Writes metaData to the out stream.

See also
{Serializing Qt Data Types}

Definition at line 291 of file qabstractnetworkcache.cpp.

References out, and QNetworkCacheMetaDataPrivate::save().

+ Here is the call graph for this function:

◆ operator>>()

QDataStream & operator>> ( QDataStream in,
QNetworkCacheMetaData metaData 
)
related
Since
4.5

Reads a QNetworkCacheMetaData from the stream in into metaData.

See also
{Serializing Qt Data Types}

Definition at line 329 of file qabstractnetworkcache.cpp.

References QNetworkCacheMetaDataPrivate::load().

+ Here is the call graph for this function:

◆ QNetworkCacheMetaDataPrivate

friend class QNetworkCacheMetaDataPrivate
friend

Definition at line 64 of file qabstractnetworkcache.h.


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