Soup.HSTSEnforcer
Description: Reference for Soup.HSTSEnforcer

### Class

# SoupHSTSEnforcer

#### Description [src]

    class Soup.HSTSEnforcer : GObject.Object {
      parent_instance: GObject
    }

Automatic HTTP Strict Transport Security enforcing for `SoupSession`.

A `SoupHSTSEnforcer` stores HSTS policies and enforces them when required. `SoupHSTSEnforcer` implements `SoupSessionFeature`, so you can add an HSTS enforcer to a session with `soup_session_add_feature()` or `soup_session_add_feature_by_type()`.

`SoupHSTSEnforcer` keeps track of all the HTTPS destinations that, when connected to, return the Strict-Transport-Security header with valid values. `SoupHSTSEnforcer` will forget those destinations upon expiry or when the server requests it.

When the `SoupSession` the `SoupHSTSEnforcer` is attached to queues or restarts a message, the `SoupHSTSEnforcer` will rewrite the URI to HTTPS if the destination is a known HSTS host and is contacted over an insecure transport protocol (HTTP). Users of `SoupHSTSEnforcer` are advised to listen to changes in the `SoupMessage:uri` property in order to be aware of changes in the message URI.

Note that `SoupHSTSEnforcer` does not support any form of long-term HSTS policy persistence. See `SoupHSTSEnforcerDB` for a persistent enforcer.

#### Ancestors

- GObject

#### Descendants

- SoupHSTSEnforcerDB

#### Implements

- SoupSessionFeature

#### Constructors

###### soup_hsts_enforcer_new

Creates a new `SoupHSTSEnforcer`.

#### Instance methods

###### soup_hsts_enforcer_get_domains

Gets a list of domains for which there are policies in `enforcer`.

###### soup_hsts_enforcer_get_policies

Gets a list with the policies in `enforcer`.

###### soup_hsts_enforcer_has_valid_policy

Gets whether `hsts_enforcer` has a currently valid policy for `domain`.

###### soup_hsts_enforcer_is_persistent

Gets whether `hsts_enforcer` stores policies persistenly.

###### soup_hsts_enforcer_set_policy

Sets `policy` to `hsts_enforcer`.

###### soup_hsts_enforcer_set_session_policy

Sets a session policy for `domain`.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

###### Soup.HSTSEnforcer::changed

Emitted when `hsts_enforcer` changes.

##### Signals inherited from GObject (1)

###### GObject.Object::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct SoupHSTSEnforcerClass {
      GObjectClass parent_class;
      gboolean (* is_persistent) (
        SoupHSTSEnforcer* hsts_enforcer
      );
      gboolean (* has_valid_policy) (
        SoupHSTSEnforcer* hsts_enforcer,
        const char* domain
      );
      void (* changed) (
        SoupHSTSEnforcer* enforcer,
        SoupHSTSPolicy* old_policy,
        SoupHSTSPolicy* new_policy
      );

    }

###### Class members

`parent_class` |
    GObjectClass
| The parent class.
`is_persistent` |
    gboolean (* is_persistent) (
        SoupHSTSEnforcer* hsts_enforcer
      )
| No description available.
`has_valid_policy` |
    gboolean (* has_valid_policy) (
        SoupHSTSEnforcer* hsts_enforcer,
        const char* domain
      )
| No description available.
`changed` |
    void (* changed) (
        SoupHSTSEnforcer* enforcer,
        SoupHSTSPolicy* old_policy,
        SoupHSTSPolicy* new_policy
      )
| No description available.

#### Virtual methods

###### Soup.HSTSEnforcerClass.changed

No description available.

###### Soup.HSTSEnforcerClass.has_valid_policy

Gets whether `hsts_enforcer` has a currently valid policy for `domain`.

###### Soup.HSTSEnforcerClass.is_persistent

Gets whether `hsts_enforcer` stores policies persistenly.