Soup.HSTSPolicy

Fields

None

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 ()

get_expires ()

get_max_age ()

includes_subdomains ()

is_expired ()

is_session_policy ()

Details

class Soup.HSTSPolicy

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. [ctor`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.

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.

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.

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 (GLib.DateTime) – 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 [ctor`HSTSPolicy`.new], to use with an existing expiration date.

See [ctor`HSTSPolicy`.new] for details.

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 [class`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.

copy()
Returns:

a copy of self

Return type:

Soup.HSTSPolicy

Copies self.

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.

free()

Frees self.

get_domain()
Returns:

self's domain.

Return type:

str

Gets self's domain.

get_expires()
Returns:

A GLib.DateTime or None if unset

Return type:

GLib.DateTime

Returns the expiration date for self.

get_max_age()
Returns:

Max age in seconds

Return type:

int

Returns the max age for self.

includes_subdomains()
Returns:

True if self includes subdomains, False otherwise.

Return type:

bool

Gets whether self include its subdomains.

is_expired()
Returns:

True if self is expired, False otherwise.

Return type:

bool

Gets whether self is expired.

Permanent policies never expire.

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 [ctor`HSTSPolicy`.new_session_policy] for details.