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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use glib::translate::*;

/// Appends something like `name=value` to @string, taking care to quote @value
/// if needed, and if so, to escape any quotes or backslashes in @value.
///
/// Alternatively, if @value is a non-ASCII UTF-8 string, it will be
/// appended using RFC5987 syntax. Although in theory this is supposed
/// to work anywhere in HTTP that uses this style of parameter, in
/// reality, it can only be used portably with the Content-Disposition
/// "filename" parameter.
///
/// If @value is [`None`], this will just append @name to @string.
/// ## `string`
/// a #GString being used to construct an HTTP header value
/// ## `name`
/// a parameter name
/// ## `value`
/// a parameter value, or [`None`]
#[doc(alias = "soup_header_g_string_append_param")]
pub fn header_g_string_append_param(header: &mut String, name: &str, value: &str) {
    unsafe {
        let hdr = glib::ffi::g_string_new_len(header.as_ptr() as *const _, header.len() as isize);
        ffi::soup_header_g_string_append_param(hdr, name.to_glib_none().0, value.to_glib_none().0);
        let s: glib::GString = from_glib_full(glib::ffi::g_string_free(hdr, glib::ffi::GFALSE));
        header.clone_from(&s.as_str().to_owned())
    }
}

/// Appends something like `name="value"` to
/// @string, taking care to escape any quotes or backslashes in @value.
///
/// If @value is (non-ASCII) UTF-8, this will instead use RFC 5987
/// encoding, just like `header_g_string_append_param()`.
/// ## `string`
/// a #GString being used to construct an HTTP header value
/// ## `name`
/// a parameter name
/// ## `value`
/// a parameter value
#[doc(alias = "soup_header_g_string_append_param_quoted")]
pub fn header_g_string_append_param_quoted(header: &mut String, name: &str, value: &str) {
    unsafe {
        let hdr = glib::ffi::g_string_new_len(header.as_ptr() as *const _, header.len() as isize);
        ffi::soup_header_g_string_append_param_quoted(
            hdr,
            name.to_glib_none().0,
            value.to_glib_none().0,
        );
        let s: glib::GString = from_glib_full(glib::ffi::g_string_free(hdr, glib::ffi::GFALSE));
        header.clone_from(&s.as_str().to_owned())
    }
}

// #[doc(alias = "soup_cookies_free")]
// pub fn cookies_free(cookies: &[&Cookie]) {
//     assert_initialized_main_thread!();
//     unsafe {
//         let cookie_list: *mut glib::ffi::GSList = ToGlibContainerFromSlice::to_glib_none_from_slice(cookies).0;
//         ffi::soup_cookies_free(cookie_list);
//     }
// }

// #[doc(alias = "soup_cookies_to_cookie_header")]
// pub fn cookies_to_cookie_header(cookies: &[Cookie]) -> Option<glib::GString> {
//     assert_initialized_main_thread!();
//     unsafe {
//         let cookie_list: *mut glib::ffi::GSList = ToGlibContainerFromSlice::to_glib_none_from_slice(cookies).0;
//         from_glib_full(ffi::soup_cookies_to_cookie_header(cookie_list))
//     }

// }

// #[doc(alias = "soup_cookies_to_request")]
// pub fn cookies_to_request(cookies: &[&Cookie], msg: &Message) {
//     skip_assert_initialized!();
//     unsafe {
//         ffi::soup_cookies_to_request(cookies.to_glib_none().0, msg.to_glib_none().0);
//     }
// }

// #[doc(alias = "soup_cookies_to_response")]
// pub fn cookies_to_response(cookies: &[Cookie], msg: &Message) {
//     skip_assert_initialized!();
//     unsafe {
//         ffi::soup_cookies_to_response(cookies.to_glib_none().0, msg.to_glib_none().0);
//     }
// }