Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
 \memberswap{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 19 of file qhstspolicy.h.

Member Enumeration Documentation

◆ PolicyFlag

\value IncludeSubDomains Indicates whether a policy must include subdomains

Enumerator
IncludeSubDomains 

Definition at line 22 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 79 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 96 of file qhstspolicy.cpp.

◆ QHstsPolicy() [3/3]

QHstsPolicy::QHstsPolicy ( const QHstsPolicy & rhs)

Creates a copy of other object.

Definition at line 108 of file qhstspolicy.cpp.

◆ ~QHstsPolicy()

QHstsPolicy::~QHstsPolicy ( )

Destructor.

Definition at line 116 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 164 of file qhstspolicy.cpp.

◆ 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 144 of file qhstspolicy.cpp.

◆ includesSubDomains()

bool QHstsPolicy::includesSubDomains ( ) const

Returns true if this policy also includes subdomains.

See also
setIncludesSubDomains()

Definition at line 184 of file qhstspolicy.cpp.

◆ 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 195 of file qhstspolicy.cpp.

◆ operator=() [1/2]

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

Copy-assignment operator, makes a copy of other.

Definition at line 123 of file qhstspolicy.cpp.

◆ operator=() [2/2]

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

Definition at line 33 of file qhstspolicy.h.

◆ setExpiry()

void QHstsPolicy::setExpiry ( const QDateTime & expiry)

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

See also
expiry()

Definition at line 154 of file qhstspolicy.cpp.

◆ 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 134 of file qhstspolicy.cpp.

◆ setIncludesSubDomains()

void QHstsPolicy::setIncludesSubDomains ( bool include)

Sets whether subdomains are included for this policy to include.

See also
includesSubDomains()

Definition at line 174 of file qhstspolicy.cpp.

◆ swap()

void QHstsPolicy::swap ( QHstsPolicy & other)
inlinenoexcept

\memberswap{policy}

Definition at line 36 of file qhstspolicy.h.

◆ operator!=

bool 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 53 of file qhstspolicy.h.

◆ operator==

bool 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 51 of file qhstspolicy.h.


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