+
+/**
+ * soup_session_add_feature:
+ * @session: a #SoupSession
+ * @feature: an object that implements #SoupSessionFeature
+ *
+ * Adds @feature's functionality to @session. You can also add a
+ * feature to the session at construct time by using the
+ * %SOUP_SESSION_ADD_FEATURE property.
+ **/
+void
+soup_session_add_feature (SoupSession *session, SoupSessionFeature *feature)
+{
+ SoupSessionPrivate *priv;
+
+ g_return_if_fail (SOUP_IS_SESSION (session));
+ g_return_if_fail (SOUP_IS_SESSION_FEATURE (feature));
+
+ priv = SOUP_SESSION_GET_PRIVATE (session);
+ priv->features = g_slist_prepend (priv->features, g_object_ref (feature));
+ soup_session_feature_attach (feature, session);
+}
+
+/**
+ * soup_session_add_feature_by_type:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of a class that implements #SoupSessionFeature
+ *
+ * Creates a new feature of type @feature_type and adds it to
+ * @session. You can use this instead of soup_session_add_feature() in
+ * the case wher you don't need to customize the new feature in any
+ * way. You can also add a feature to the session at construct time by
+ * using the %SOUP_SESSION_ADD_FEATURE_BY_TYPE property.
+ **/
+void
+soup_session_add_feature_by_type (SoupSession *session, GType feature_type)
+{
+ SoupSessionFeature *feature;
+
+ g_return_if_fail (SOUP_IS_SESSION (session));
+ g_return_if_fail (g_type_is_a (feature_type, SOUP_TYPE_SESSION_FEATURE));
+
+ feature = g_object_new (feature_type, NULL);
+ soup_session_add_feature (session, feature);
+ g_object_unref (feature);
+}
+
+/**
+ * soup_session_remove_feature:
+ * @session: a #SoupSession
+ * @feature: a feature that has previously been added to @session
+ *
+ * Removes @feature's functionality from @session.
+ **/
+void
+soup_session_remove_feature (SoupSession *session, SoupSessionFeature *feature)
+{
+ SoupSessionPrivate *priv;
+
+ g_return_if_fail (SOUP_IS_SESSION (session));
+
+ priv = SOUP_SESSION_GET_PRIVATE (session);
+ if (g_slist_find (priv->features, feature)) {
+ priv->features = g_slist_remove (priv->features, feature);
+ soup_session_feature_detach (feature, session);
+ g_object_unref (feature);
+ }
+}
+
+/**
+ * soup_session_remove_feature_by_type:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of a class that implements #SoupSessionFeature
+ *
+ * Removes all features of type @feature_type (or any subclass of
+ * @feature_type) from @session. You can also remove standard features
+ * from the session at construct time by using the
+ * %SOUP_SESSION_REMOVE_FEATURE_BY_TYPE property.
+ **/
+void
+soup_session_remove_feature_by_type (SoupSession *session, GType feature_type)
+{
+ SoupSessionPrivate *priv;
+ GSList *f;
+
+ g_return_if_fail (SOUP_IS_SESSION (session));
+
+ priv = SOUP_SESSION_GET_PRIVATE (session);
+restart:
+ for (f = priv->features; f; f = f->next) {
+ if (G_TYPE_CHECK_INSTANCE_TYPE (f->data, feature_type)) {
+ soup_session_remove_feature (session, f->data);
+ goto restart;
+ }
+ }
+}