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>.
Loading...
Searching...
No Matches
QHstsPolicy Class Reference

The QHstsPolicy class specifies that a host supports HTTP Strict Transport Security policy (HSTS). More...

#include <qhstspolicy.h>

+ Collaboration diagram for QHstsPolicy:

Public Types

enum  PolicyFlag { IncludeSubDomains = 1 }
 \value IncludeSubDomains Indicates whether a policy must include subdomains More...
 

Public Member Functions

 QHstsPolicy ()
 Constructs an invalid (expired) policy with empty host name and subdomains not included.
 
 QHstsPolicy (const QDateTime &expiry, PolicyFlags flags, const QString &host, QUrl::ParsingMode mode=QUrl::DecodedMode)
 Constructs QHstsPolicy with expiry (in UTC); flags is a value indicating whether this policy must also include subdomains, host data is interpreted according to mode.
 
 QHstsPolicy (const QHstsPolicy &rhs)
 Creates a copy of other object.
 
QHstsPolicyoperator= (const QHstsPolicy &rhs)
 Copy-assignment operator, makes a copy of other.
 
QHstsPolicyoperator= (QHstsPolicy &&other) noexcept
 
 ~QHstsPolicy ()
 Destructor.
 
void swap (QHstsPolicy &other) noexcept
 Swaps this policy with the other policy.
 
void setHost (const QString &host, QUrl::ParsingMode mode=QUrl::DecodedMode)
 Sets a host, host data is interpreted according to mode parameter.
 
QString host (QUrl::ComponentFormattingOptions options=QUrl::FullyDecoded) const
 Returns a host for a given policy, formatted according to options.
 
void setExpiry (const QDateTime &expiry)
 Sets the expiration date for the policy (in UTC) to expiry.
 
QDateTime expiry () const
 Returns the expiration date for the policy (in UTC).
 
void setIncludesSubDomains (bool include)
 Sets whether subdomains are included for this policy to include.
 
bool includesSubDomains () const
 Returns true if this policy also includes subdomains.
 
bool isExpired () const
 Return true if this policy has a valid expiration date and this date is greater than QDateTime::currentGetDateTimeUtc().
 

Friends

bool operator== (const QHstsPolicy &lhs, const QHstsPolicy &rhs)
 Returns true if the two policies lhs and rhs have the same host and expiration date while agreeing on whether to include or exclude subdomains.
 
bool operator!= (const QHstsPolicy &lhs, const QHstsPolicy &rhs)
 Returns true if the two policies lhs and rhs do not have the same host or expiration date, or do not agree on whether to include or exclude subdomains.
 

Detailed Description

The QHstsPolicy class specifies that a host supports HTTP Strict Transport Security policy (HSTS).

Since
5.9

\inmodule QtNetwork

HSTS policy defines a period of time during which QNetworkAccessManager should only access a host in a secure fashion. HSTS policy is defined by RFC6797.

You can set expiry time and host name for this policy, and control whether it applies to subdomains, either in the constructor or by calling \l setExpiry(), \l setHost() and \l setIncludesSubDomains().

See also
QNetworkAccessManager::setStrictTransportSecurityEnabled()

Definition at line 18 of file qhstspolicy.h.

Member Enumeration Documentation

◆ PolicyFlag

\value IncludeSubDomains Indicates whether a policy must include subdomains

Enumerator
IncludeSubDomains 

Definition at line 21 of file qhstspolicy.h.

Constructor & Destructor Documentation

◆ QHstsPolicy() [1/3]

QHstsPolicy::QHstsPolicy ( )

Constructs an invalid (expired) policy with empty host name and subdomains not included.

Definition at line 78 of file qhstspolicy.cpp.

◆ QHstsPolicy() [2/3]

QHstsPolicy::QHstsPolicy ( const QDateTime & expiry,
PolicyFlags flags,
const QString & host,
QUrl::ParsingMode mode = QUrl::DecodedMode )

Constructs QHstsPolicy with expiry (in UTC); flags is a value indicating whether this policy must also include subdomains, host data is interpreted according to mode.

See also
QUrl::setHost(), QUrl::ParsingMode, QHstsPolicy::PolicyFlag

Definition at line 95 of file qhstspolicy.cpp.

References QHstsPolicyPrivate::expiry, expiry(), host(), QHstsPolicyPrivate::includeSubDomains, IncludeSubDomains, QUrl::setHost(), and QHstsPolicyPrivate::url.

+ Here is the call graph for this function:

◆ QHstsPolicy() [3/3]

QHstsPolicy::QHstsPolicy ( const QHstsPolicy & rhs)

Creates a copy of other object.

Definition at line 107 of file qhstspolicy.cpp.

◆ ~QHstsPolicy()

QHstsPolicy::~QHstsPolicy ( )

Destructor.

Definition at line 115 of file qhstspolicy.cpp.

Member Function Documentation

◆ expiry()

QDateTime QHstsPolicy::expiry ( ) const

Returns the expiration date for the policy (in UTC).

See also
setExpiry()

Definition at line 163 of file qhstspolicy.cpp.

References QHstsPolicyPrivate::expiry.

Referenced by QHstsPolicy(), and setExpiry().

+ Here is the caller graph for this function:

◆ host()

QString QHstsPolicy::host ( QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const

Returns a host for a given policy, formatted according to options.

See also
setHost(), QUrl::host(), QUrl::ComponentFormattingOptions

Definition at line 143 of file qhstspolicy.cpp.

References QUrl::host(), and QHstsPolicyPrivate::url.

Referenced by QHstsPolicy(), and setHost().

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

◆ includesSubDomains()

bool QHstsPolicy::includesSubDomains ( ) const

Returns true if this policy also includes subdomains.

See also
setIncludesSubDomains()

Definition at line 183 of file qhstspolicy.cpp.

References QHstsPolicyPrivate::includeSubDomains.

◆ isExpired()

bool QHstsPolicy::isExpired ( ) const

Return true if this policy has a valid expiration date and this date is greater than QDateTime::currentGetDateTimeUtc().

See also
setExpiry(), expiry()

Definition at line 194 of file qhstspolicy.cpp.

References QDateTime::currentDateTimeUtc(), QHstsPolicyPrivate::expiry, and QDateTime::isValid().

+ Here is the call graph for this function:

◆ operator=() [1/2]

QHstsPolicy & QHstsPolicy::operator= ( const QHstsPolicy & rhs)

Copy-assignment operator, makes a copy of other.

Definition at line 122 of file qhstspolicy.cpp.

References other().

+ Here is the call graph for this function:

◆ operator=() [2/2]

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

Definition at line 32 of file qhstspolicy.h.

References other(), and swap().

+ Here is the call graph for this function:

◆ setExpiry()

void QHstsPolicy::setExpiry ( const QDateTime & expiry)

Sets the expiration date for the policy (in UTC) to expiry.

See also
expiry()

Definition at line 153 of file qhstspolicy.cpp.

References QHstsPolicyPrivate::expiry, and expiry().

+ Here is the call graph for this function:

◆ setHost()

void QHstsPolicy::setHost ( const QString & host,
QUrl::ParsingMode mode = QUrl::DecodedMode )

Sets a host, host data is interpreted according to mode parameter.

See also
host(), QUrl::setHost(), QUrl::ParsingMode

Definition at line 133 of file qhstspolicy.cpp.

References host(), QUrl::setHost(), and QHstsPolicyPrivate::url.

Referenced by QHstsStore::readPolicies().

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

◆ setIncludesSubDomains()

void QHstsPolicy::setIncludesSubDomains ( bool include)

Sets whether subdomains are included for this policy to include.

See also
includesSubDomains()

Definition at line 173 of file qhstspolicy.cpp.

References QHstsPolicyPrivate::includeSubDomains.

◆ swap()

void QHstsPolicy::swap ( QHstsPolicy & other)
inlinenoexcept

Swaps this policy with the other policy.

Definition at line 35 of file qhstspolicy.h.

References d, and other().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool QHstsPolicy::operator!= ( const QHstsPolicy & lhs,
const QHstsPolicy & rhs )
friend

Returns true if the two policies lhs and rhs do not have the same host or expiration date, or do not agree on whether to include or exclude subdomains.

Definition at line 52 of file qhstspolicy.h.

◆ operator==

bool QHstsPolicy::operator== ( const QHstsPolicy & lhs,
const QHstsPolicy & rhs )
friend

Returns true if the two policies lhs and rhs have the same host and expiration date while agreeing on whether to include or exclude subdomains.

Definition at line 50 of file qhstspolicy.h.


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