:right-sidebar: True HSTSPolicy =================================================================== .. currentmodule:: gi.repository.Soup .. class:: HSTSPolicy(**kwargs) :no-contents-entry: :obj:`~gi.repository.Soup.HSTSPolicy` implements HTTP policies, as described by `RFC 6797 `__\. ``domain`` represents the host that this policy applies to. The domain must be IDNA-canonicalized. :obj:`~gi.repository.HSTSPolicy.new` and related methods will do this for you. ``max_age`` contains the 'max-age' value from the Strict Transport Security header and indicates the time to live of this policy, in seconds. ``expires`` will be non-:const:`None` if the policy has been set by the host and hence has an expiry time. If ``expires`` is :const:`None`, it indicates that the policy is a permanent session policy set by the user agent. If ``include_subdomains`` is :const:`True`, the Strict Transport Security policy must also be enforced on subdomains of ``domain``\. Constructors ------------ .. rst-class:: interim-class .. class:: HSTSPolicy :no-index: .. classmethod:: new(domain: str, max_age: int, include_subdomains: bool) -> ~gi.repository.Soup.HSTSPolicy Creates a new :obj:`~gi.repository.Soup.HSTSPolicy` with the given attributes. ``domain`` is a domain on which the strict transport security policy represented by this object must be enforced. ``max_age`` is used to set the "expires" attribute on the policy; pass :const:`~gi.repository.Soup.HSTS_POLICY_MAX_AGE_PAST` for an already-expired policy, or a lifetime in seconds. If ``include_subdomains`` is :const:`True`, the strict transport security policy must also be enforced on all subdomains of ``domain``\. :param domain: policy domain or hostname :param max_age: max age of the policy :param include_subdomains: :const:`True` if the policy applies on subdomains .. classmethod:: new_from_response(msg: ~gi.repository.Soup.Message) -> ~gi.repository.Soup.HSTSPolicy | None Parses ``msg``\'s first "Strict-Transport-Security" response header and returns a :obj:`~gi.repository.Soup.HSTSPolicy`\. :param msg: a :obj:`~gi.repository.Soup.Message` .. classmethod:: new_full(domain: str, max_age: int, expires: ~gi.repository.GLib.DateTime, include_subdomains: bool) -> ~gi.repository.Soup.HSTSPolicy Full version of :obj:`~gi.repository.HSTSPolicy.new`\, to use with an existing expiration date. See :obj:`~gi.repository.HSTSPolicy.new` for details. :param domain: policy domain or hostname :param max_age: max age of the policy :param expires: the date of expiration of the policy or :const:`None` for a permanent policy :param include_subdomains: :const:`True` if the policy applies on subdomains .. classmethod:: new_session_policy(domain: str, include_subdomains: bool) -> ~gi.repository.Soup.HSTSPolicy Creates a new session :obj:`~gi.repository.Soup.HSTSPolicy` with the given attributes. A session policy is a policy that is valid during the lifetime of the :obj:`~gi.repository.Soup.HSTSEnforcer` it is added to. Contrary to regular policies, it has no expiration date and is not stored in persistent enforcers. These policies are useful for user-agent to load their own or user-defined rules. ``domain`` is a domain on which the strict transport security policy represented by this object must be enforced. If ``include_subdomains`` is :const:`True`, the strict transport security policy must also be enforced on all subdomains of ``domain``\. :param domain: policy domain or hostname :param include_subdomains: :const:`True` if the policy applies on sub domains Methods ------- .. rst-class:: interim-class .. class:: HSTSPolicy :no-index: .. method:: equal(policy2: ~gi.repository.Soup.HSTSPolicy) -> bool Tests if ``policy1`` and ``policy2`` are equal. :param policy2: a :obj:`~gi.repository.Soup.HSTSPolicy` .. method:: free() -> None Frees ``policy``\. .. method:: get_domain() -> str Gets ``policy``\'s domain. .. method:: get_expires() -> ~gi.repository.GLib.DateTime Returns the expiration date for ``policy``\. .. method:: get_max_age() -> int Returns the max age for ``policy``\. .. method:: includes_subdomains() -> bool Gets whether ``policy`` include its subdomains. .. method:: is_expired() -> bool Gets whether ``policy`` is expired. Permanent policies never expire. .. method:: is_session_policy() -> bool Gets whether ``policy`` is a non-permanent, non-expirable session policy. See :obj:`~gi.repository.HSTSPolicy.new_session_policy` for details.