1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{Auth, SessionFeature};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// HTTP client-side authentication handler.
    ///
    /// #SoupAuthManager is the [`SessionFeature`][crate::SessionFeature] that handles HTTP
    /// authentication for a [`Session`][crate::Session].
    ///
    /// A #SoupAuthManager is added to the session by default, and normally
    /// you don't need to worry about it at all. However, if you want to
    /// disable HTTP authentication, you can remove the feature from the
    /// session with [`SessionExt::remove_feature_by_type()`][crate::prelude::SessionExt::remove_feature_by_type()] or disable it on
    /// individual requests with [`Message::disable_feature()`][crate::Message::disable_feature()].
    ///
    /// You can use this with [`SessionExt::remove_feature_by_type()`][crate::prelude::SessionExt::remove_feature_by_type()] or
    /// [`Message::disable_feature()`][crate::Message::disable_feature()].
    ///
    /// (Although this type has only been publicly visible since libsoup 2.42, it has
    /// always existed in the background, and you can use `g_type_from_name
    /// ("SoupAuthManager")` to get its `alias::GLib.Type` in earlier releases.)
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`], [`SessionFeatureExt`][trait@crate::prelude::SessionFeatureExt]
    #[doc(alias = "SoupAuthManager")]
    pub struct AuthManager(Object<ffi::SoupAuthManager, ffi::SoupAuthManagerClass>) @implements SessionFeature;

    match fn {
        type_ => || ffi::soup_auth_manager_get_type(),
    }
}

impl AuthManager {
    /// Clear all credentials cached by @self.
    #[doc(alias = "soup_auth_manager_clear_cached_credentials")]
    pub fn clear_cached_credentials(&self) {
        unsafe {
            ffi::soup_auth_manager_clear_cached_credentials(self.to_glib_none().0);
        }
    }

    /// Records that @auth is to be used under @uri, as though a
    /// WWW-Authenticate header had been received at that URI.
    ///
    /// This can be used to "preload" @self's auth cache, to avoid an extra HTTP
    /// round trip in the case where you know ahead of time that a 401 response will
    /// be returned.
    ///
    /// This is only useful for authentication types where the initial
    /// Authorization header does not depend on any additional information
    /// from the server. (Eg, Basic or NTLM, but not Digest.)
    /// ## `uri`
    /// the #GUri under which @auth is to be used
    /// ## `auth`
    /// the #SoupAuth to use
    #[doc(alias = "soup_auth_manager_use_auth")]
    pub fn use_auth(&self, uri: &glib::Uri, auth: &impl IsA<Auth>) {
        unsafe {
            ffi::soup_auth_manager_use_auth(
                self.to_glib_none().0,
                uri.to_glib_none().0,
                auth.as_ref().to_glib_none().0,
            );
        }
    }
}