Soup.HSTSPolicy

Fields

Name

Type

Access

Description

domain

str

r/w

The domain or hostname that the policy applies to

expires

Soup.Date

r/w

the policy expiration time, or None for a permanent session policy

include_subdomains

bool

r/w

True if the policy applies on subdomains

max_age

int

r/w

The maximum age, in seconds, that the policy is valid

Methods

class

new (domain, max_age, include_subdomains)

class

new_from_response (msg)

class

new_full (domain, max_age, expires, include_subdomains)

class

new_session_policy (domain, include_subdomains)

copy ()

equal (policy2)

free ()

get_domain ()

includes_subdomains ()

is_expired ()

is_session_policy ()

Details

class Soup.HSTSPolicy

An HTTP Strict Transport Security policy.

domain represents the host that this policy applies to. The domain must be IDNA-canonicalized. Soup.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-None if the policy has been set by the host and hence has an expiry time. If expires is None, it indicates that the policy is a permanent session policy set by the user agent.

If include_subdomains is True, the Strict Transport Security policy must also be enforced on subdomains of domain.

New in version 2.68.

classmethod new(domain, max_age, include_subdomains)
Parameters:
  • domain (str) – policy domain or hostname

  • max_age (int) – max age of the policy

  • include_subdomains (bool) – True if the policy applies on subdomains

Returns:

a new Soup.HSTSPolicy.

Return type:

Soup.HSTSPolicy

Creates a new 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 Soup.HSTS_POLICY_MAX_AGE_PAST for an already-expired policy, or a lifetime in seconds.

If include_subdomains is True, the strict transport security policy must also be enforced on all subdomains of domain.

New in version 2.68.

classmethod new_from_response(msg)
Parameters:

msg (Soup.Message) – a Soup.Message

Returns:

a new Soup.HSTSPolicy, or None if no valid “Strict-Transport-Security” response header was found.

Return type:

Soup.HSTSPolicy or None

Parses msg's first “Strict-Transport-Security” response header and returns a Soup.HSTSPolicy.

New in version 2.68.

classmethod new_full(domain, max_age, expires, include_subdomains)
Parameters:
  • domain (str) – policy domain or hostname

  • max_age (int) – max age of the policy

  • expires (Soup.Date) – the date of expiration of the policy or None for a permanent policy

  • include_subdomains (bool) – True if the policy applies on subdomains

Returns:

a new Soup.HSTSPolicy.

Return type:

Soup.HSTSPolicy

Full version of Soup.HSTSPolicy.new(), to use with an existing expiration date. See Soup.HSTSPolicy.new() for details.

New in version 2.68.

classmethod new_session_policy(domain, include_subdomains)
Parameters:
  • domain (str) – policy domain or hostname

  • include_subdomains (bool) – True if the policy applies on sub domains

Returns:

a new Soup.HSTSPolicy.

Return type:

Soup.HSTSPolicy

Creates a new session Soup.HSTSPolicy with the given attributes. A session policy is a policy that is valid during the lifetime of the 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 True, the strict transport security policy must also be enforced on all subdomains of domain.

New in version 2.68.

copy()
Returns:

a copy of self

Return type:

Soup.HSTSPolicy

Copies self.

New in version 2.68.

equal(policy2)
Parameters:

policy2 (Soup.HSTSPolicy) – a Soup.HSTSPolicy

Returns:

whether the policies are equal.

Return type:

bool

Tests if self and policy2 are equal.

New in version 2.68.

free()

Frees self.

New in version 2.68.

get_domain()
Returns:

self's domain.

Return type:

str

Gets self's domain.

New in version 2.68.

includes_subdomains()
Returns:

True if self includes subdomains, False otherwise.

Return type:

bool

Gets whether self include its subdomains.

New in version 2.68.

is_expired()
Returns:

True if self is expired, False otherwise.

Return type:

bool

Gets whether self is expired. Permanent policies never expire.

New in version 2.68.

is_session_policy()
Returns:

True if self is permanent, False otherwise

Return type:

bool

Gets whether self is a non-permanent, non-expirable session policy. see Soup.HSTSPolicy.new_session_policy() for details.

New in version 2.68.