QHstsPolicy 类

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

头: #include <QHstsPolicy>
CMake: find_package(Qt6 COMPONENTS Network REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network
Since: Qt 5.9

公共类型

enum PolicyFlag { IncludeSubDomains }
flags PolicyFlags

公共函数

  QHstsPolicy (const QHstsPolicy & other )
  QHstsPolicy (const QDateTime & expiry , QHstsPolicy::PolicyFlags flags , const QString & host , QUrl::ParsingMode mode = QUrl::DecodedMode)
  QHstsPolicy ()
QHstsPolicy & operator= (const QHstsPolicy & other )
  ~QHstsPolicy ()
QDateTime expiry () const
QString host (QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const
bool includesSubDomains () const
bool isExpired () const
void setExpiry (const QDateTime & expiry )
void setHost (const QString & host , QUrl::ParsingMode mode = QUrl::DecodedMode)
void setIncludesSubDomains (bool 包括 )
void swap (QHstsPolicy & other )
bool operator!= (const QHstsPolicy & lhs , const QHstsPolicy & rhs )
bool operator== (const QHstsPolicy & lhs , const QHstsPolicy & rhs )

详细描述

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 setExpiry (), setHost () and setIncludesSubdomains().

另请参阅 QNetworkAccessManager::setStrictTransportSecurityEnabled ().

成员类型文档编制

enum QHstsPolicy:: PolicyFlag
flags QHstsPolicy:: PolicyFlags

常量 描述
QHstsPolicy::IncludeSubDomains 1 Indicates whether a policy must include subdomains

The PolicyFlags type is a typedef for QFlags <PolicyFlag>. It stores an OR combination of PolicyFlag values.

成员函数文档编制

QHstsPolicy:: QHstsPolicy (const QHstsPolicy & other )

创建副本为 other 对象。

QHstsPolicy:: QHstsPolicy (const QDateTime & expiry , QHstsPolicy::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 .

另请参阅 QUrl::setHost (), QUrl::ParsingMode ,和 QHstsPolicy::PolicyFlag .

QHstsPolicy:: QHstsPolicy ()

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

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

Copy-assignment operator, makes a copy of other .

QHstsPolicy:: ~QHstsPolicy ()

析构函数。

QDateTime QHstsPolicy:: expiry () const

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

另请参阅 setExpiry ().

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

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

另请参阅 setHost (), QUrl::host (),和 QUrl::ComponentFormattingOptions .

bool QHstsPolicy:: includesSubDomains () const

返回 true if this policy also includes subdomains.

另请参阅 setIncludesSubDomains ().

bool QHstsPolicy:: isExpired () const

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

另请参阅 setExpiry () 和 expiry ().

void QHstsPolicy:: setExpiry (const QDateTime & expiry )

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

另请参阅 expiry ().

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

Sets a host, host data is interpreted according to mode 参数。

另请参阅 host (), QUrl::setHost (),和 QUrl::ParsingMode .

void QHstsPolicy:: setIncludesSubDomains ( bool 包括 )

Sets whether subdomains are included for this policy to 包括 .

另请参阅 includesSubDomains ().

void QHstsPolicy:: swap ( QHstsPolicy & other )

Swaps this policy with the other policy.

相关非成员

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

返回 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.

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

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