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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
use crate::Cookie;
use crate::DateFormat;
use crate::HTTPVersion;
use crate::Message;
use crate::MessageHeaders;
use glib::translate::*;
use std::mem;
use std::ptr;
#[doc(alias = "soup_check_version")]
pub fn check_version(major: u32, minor: u32, micro: u32) -> bool {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::soup_check_version(major, minor, micro)) }
}
#[doc(alias = "soup_cookies_from_request")]
pub fn cookies_from_request(msg: &Message) -> Vec<Cookie> {
skip_assert_initialized!();
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::soup_cookies_from_request(msg.to_glib_none().0))
}
}
#[doc(alias = "soup_cookies_from_response")]
pub fn cookies_from_response(msg: &Message) -> Vec<Cookie> {
skip_assert_initialized!();
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::soup_cookies_from_response(msg.to_glib_none().0))
}
}
#[doc(alias = "soup_date_time_new_from_http_string")]
pub fn date_time_new_from_http_string(date_string: &str) -> Option<glib::DateTime> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::soup_date_time_new_from_http_string(
date_string.to_glib_none().0,
))
}
}
#[doc(alias = "soup_date_time_to_string")]
pub fn date_time_to_string(date: &glib::DateTime, format: DateFormat) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::soup_date_time_to_string(
date.to_glib_none().0,
format.into_glib(),
))
}
}
#[doc(alias = "soup_get_major_version")]
#[doc(alias = "get_major_version")]
pub fn major_version() -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::soup_get_major_version() }
}
#[doc(alias = "soup_get_micro_version")]
#[doc(alias = "get_micro_version")]
pub fn micro_version() -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::soup_get_micro_version() }
}
#[doc(alias = "soup_get_minor_version")]
#[doc(alias = "get_minor_version")]
pub fn minor_version() -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::soup_get_minor_version() }
}
#[doc(alias = "soup_header_contains")]
pub fn header_contains(header: &str, token: &str) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::soup_header_contains(
header.to_glib_none().0,
token.to_glib_none().0,
))
}
}
#[doc(alias = "soup_header_parse_list")]
pub fn header_parse_list(header: &str) -> Vec<glib::GString> {
assert_initialized_main_thread!();
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::soup_header_parse_list(header.to_glib_none().0))
}
}
#[doc(alias = "soup_headers_parse")]
pub fn headers_parse(str: &str, dest: &MessageHeaders) -> bool {
assert_initialized_main_thread!();
let len = str.len() as i32;
unsafe {
from_glib(ffi::soup_headers_parse(
str.to_glib_none().0,
len,
dest.to_glib_none().0,
))
}
}
#[doc(alias = "soup_headers_parse_request")]
pub fn headers_parse_request(
str: &str,
req_headers: &MessageHeaders,
) -> (u32, glib::GString, glib::GString, HTTPVersion) {
assert_initialized_main_thread!();
let len = str.len() as i32;
unsafe {
let mut req_method = ptr::null_mut();
let mut req_path = ptr::null_mut();
let mut ver = mem::MaybeUninit::uninit();
let ret = ffi::soup_headers_parse_request(
str.to_glib_none().0,
len,
req_headers.to_glib_none().0,
&mut req_method,
&mut req_path,
ver.as_mut_ptr(),
);
(
ret,
from_glib_full(req_method),
from_glib_full(req_path),
from_glib(ver.assume_init()),
)
}
}
#[doc(alias = "soup_headers_parse_response")]
pub fn headers_parse_response(
str: &str,
headers: &MessageHeaders,
) -> Option<(HTTPVersion, u32, glib::GString)> {
assert_initialized_main_thread!();
let len = str.len() as i32;
unsafe {
let mut ver = mem::MaybeUninit::uninit();
let mut status_code = mem::MaybeUninit::uninit();
let mut reason_phrase = ptr::null_mut();
let ret = from_glib(ffi::soup_headers_parse_response(
str.to_glib_none().0,
len,
headers.to_glib_none().0,
ver.as_mut_ptr(),
status_code.as_mut_ptr(),
&mut reason_phrase,
));
if ret {
Some((
from_glib(ver.assume_init()),
status_code.assume_init(),
from_glib_full(reason_phrase),
))
} else {
None
}
}
}
#[doc(alias = "soup_headers_parse_status_line")]
pub fn headers_parse_status_line(status_line: &str) -> Option<(HTTPVersion, u32, glib::GString)> {
assert_initialized_main_thread!();
unsafe {
let mut ver = mem::MaybeUninit::uninit();
let mut status_code = mem::MaybeUninit::uninit();
let mut reason_phrase = ptr::null_mut();
let ret = from_glib(ffi::soup_headers_parse_status_line(
status_line.to_glib_none().0,
ver.as_mut_ptr(),
status_code.as_mut_ptr(),
&mut reason_phrase,
));
if ret {
Some((
from_glib(ver.assume_init()),
status_code.assume_init(),
from_glib_full(reason_phrase),
))
} else {
None
}
}
}
#[doc(alias = "soup_tld_domain_is_public_suffix")]
pub fn tld_domain_is_public_suffix(domain: &str) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::soup_tld_domain_is_public_suffix(
domain.to_glib_none().0,
))
}
}
#[doc(alias = "soup_tld_get_base_domain")]
pub fn tld_get_base_domain(hostname: &str) -> Result<glib::GString, glib::Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::soup_tld_get_base_domain(hostname.to_glib_none().0, &mut error);
if error.is_null() {
Ok(from_glib_none(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "soup_uri_decode_data_uri")]
pub fn uri_decode_data_uri(uri: &str) -> (glib::Bytes, Option<glib::GString>) {
assert_initialized_main_thread!();
unsafe {
let mut content_type = ptr::null_mut();
let ret = from_glib_full(ffi::soup_uri_decode_data_uri(
uri.to_glib_none().0,
&mut content_type,
));
(ret, from_glib_full(content_type))
}
}
#[doc(alias = "soup_uri_equal")]
pub fn uri_equal(uri1: &glib::Uri, uri2: &glib::Uri) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::soup_uri_equal(
uri1.to_glib_none().0,
uri2.to_glib_none().0,
))
}
}