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 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
// 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::{HTTPVersion, MemoryUse, MessageBody, MessageHeaders};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// An HTTP server request and response pair.
///
/// A SoupServerMessage represents an HTTP message that is being sent or
/// received on a [`Server`][crate::Server].
///
/// [`Server`][crate::Server] will create `SoupServerMessage`s automatically for
/// incoming requests, which your application will receive via handlers.
///
/// Note that libsoup's terminology here does not quite match the HTTP
/// specification: in RFC 2616, an "HTTP-message" is *either* a Request, *or* a
/// Response. In libsoup, a #SoupServerMessage combines both the request and the
/// response.
///
/// ## Properties
///
///
/// #### `tls-peer-certificate`
/// The peer's #GTlsCertificate associated with the message
///
/// Readable
///
///
/// #### `tls-peer-certificate-errors`
/// The verification errors on #SoupServerMessage:tls-peer-certificate
///
/// Readable
///
/// ## Signals
///
///
/// #### `accept-certificate`
/// Emitted during the @msg's connection TLS handshake
/// after client TLS certificate has been received.
/// You can return [`true`] to accept @tls_certificate despite
/// @tls_errors.
///
///
///
///
/// #### `connected`
/// Emitted when the @msg's socket is connected and the TLS handshake completed.
///
///
///
///
/// #### `disconnected`
/// Emitted when the @msg's socket is disconnected.
///
///
///
///
/// #### `finished`
/// Emitted when all HTTP processing is finished for a message.
/// (After [`wrote-body`][struct@crate::ServerMessage#wrote-body]).
///
///
///
///
/// #### `got-body`
/// Emitted after receiving the complete request body.
///
///
///
///
/// #### `got-chunk`
/// Emitted after receiving a chunk of a message body.
///
/// Note that "chunk" in this context means any subpiece of the body, not
/// necessarily the specific HTTP 1.1 chunks sent by the other side.
///
///
///
///
/// #### `got-headers`
/// Emitted after receiving the Request-Line and request headers.
///
///
///
///
/// #### `wrote-body`
/// Emitted immediately after writing the complete response body for a
/// message.
///
///
///
///
/// #### `wrote-body-data`
/// Emitted immediately after writing a portion of the message
/// body to the network.
///
///
///
///
/// #### `wrote-chunk`
/// Emitted immediately after writing a body chunk for a message.
///
/// Note that this signal is not parallel to
/// [`got-chunk`][struct@crate::ServerMessage#got-chunk]; it is emitted only when a complete
/// chunk (added with `MessageBody::append()` or
/// [`MessageBody::append_bytes()`][crate::MessageBody::append_bytes()] has been written. To get
/// more useful continuous progress information, use
/// [`wrote-body-data`][struct@crate::ServerMessage#wrote-body-data].
///
///
///
///
/// #### `wrote-headers`
/// Emitted immediately after writing the response headers for a
/// message.
///
///
///
///
/// #### `wrote-informational`
/// Emitted immediately after writing a 1xx (Informational) response.
///
///
///
/// # Implements
///
/// [`trait@glib::ObjectExt`]
#[doc(alias = "SoupServerMessage")]
pub struct ServerMessage(Object<ffi::SoupServerMessage, ffi::SoupServerMessageClass>);
match fn {
type_ => || ffi::soup_server_message_get_type(),
}
}
impl ServerMessage {
/// Get the HTTP version of @self.
///
/// # Returns
///
/// a #SoupHTTPVersion.
#[doc(alias = "soup_server_message_get_http_version")]
#[doc(alias = "get_http_version")]
pub fn http_version(&self) -> HTTPVersion {
unsafe {
from_glib(ffi::soup_server_message_get_http_version(
self.to_glib_none().0,
))
}
}
/// Retrieves the [`gio::SocketAddress`][crate::gio::SocketAddress] associated with the local end
/// of a connection.
///
/// # Returns
///
/// the #GSocketAddress
/// associated with the local end of a connection, it may be
/// [`None`] if you used [`ServerExt::accept_iostream()`][crate::prelude::ServerExt::accept_iostream()].
#[doc(alias = "soup_server_message_get_local_address")]
#[doc(alias = "get_local_address")]
pub fn local_address(&self) -> Option<gio::SocketAddress> {
unsafe {
from_glib_none(ffi::soup_server_message_get_local_address(
self.to_glib_none().0,
))
}
}
/// Get the HTTP method of @self.
///
/// # Returns
///
/// the HTTP method.
#[doc(alias = "soup_server_message_get_method")]
#[doc(alias = "get_method")]
pub fn method(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::soup_server_message_get_method(self.to_glib_none().0)) }
}
/// Get the HTTP reason phrase of @self.
///
/// # Returns
///
/// the reason phrase.
#[doc(alias = "soup_server_message_get_reason_phrase")]
#[doc(alias = "get_reason_phrase")]
pub fn reason_phrase(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::soup_server_message_get_reason_phrase(
self.to_glib_none().0,
))
}
}
/// Retrieves the [`gio::SocketAddress`][crate::gio::SocketAddress] associated with the remote end
/// of a connection.
///
/// # Returns
///
/// the #GSocketAddress
/// associated with the remote end of a connection, it may be
/// [`None`] if you used `Server::accept_iostream`.
#[doc(alias = "soup_server_message_get_remote_address")]
#[doc(alias = "get_remote_address")]
pub fn remote_address(&self) -> Option<gio::SocketAddress> {
unsafe {
from_glib_none(ffi::soup_server_message_get_remote_address(
self.to_glib_none().0,
))
}
}
/// Retrieves the IP address associated with the remote end of a
/// connection.
///
/// # Returns
///
/// the IP address associated with the remote
/// end of a connection, it may be [`None`] if you used
/// [`ServerExt::accept_iostream()`][crate::prelude::ServerExt::accept_iostream()].
#[doc(alias = "soup_server_message_get_remote_host")]
#[doc(alias = "get_remote_host")]
pub fn remote_host(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::soup_server_message_get_remote_host(
self.to_glib_none().0,
))
}
}
/// Get the request body of @self.
///
/// # Returns
///
/// a #SoupMessageBody.
#[doc(alias = "soup_server_message_get_request_body")]
#[doc(alias = "get_request_body")]
pub fn request_body(&self) -> Option<MessageBody> {
unsafe {
from_glib_none(ffi::soup_server_message_get_request_body(
self.to_glib_none().0,
))
}
}
/// Get the request headers of @self.
///
/// # Returns
///
/// a #SoupMessageHeaders with the request headers.
#[doc(alias = "soup_server_message_get_request_headers")]
#[doc(alias = "get_request_headers")]
pub fn request_headers(&self) -> Option<MessageHeaders> {
unsafe {
from_glib_none(ffi::soup_server_message_get_request_headers(
self.to_glib_none().0,
))
}
}
/// Get the response body of @self.
///
/// # Returns
///
/// a #SoupMessageBody.
#[doc(alias = "soup_server_message_get_response_body")]
#[doc(alias = "get_response_body")]
pub fn response_body(&self) -> Option<MessageBody> {
unsafe {
from_glib_none(ffi::soup_server_message_get_response_body(
self.to_glib_none().0,
))
}
}
/// Get the response headers of @self.
///
/// # Returns
///
/// a #SoupMessageHeaders with the response headers.
#[doc(alias = "soup_server_message_get_response_headers")]
#[doc(alias = "get_response_headers")]
pub fn response_headers(&self) -> Option<MessageHeaders> {
unsafe {
from_glib_none(ffi::soup_server_message_get_response_headers(
self.to_glib_none().0,
))
}
}
/// Retrieves the [`gio::Socket`][crate::gio::Socket] that @self is associated with.
///
/// If you are using this method to observe when multiple requests are
/// made on the same persistent HTTP connection (eg, as the ntlm-test
/// test program does), you will need to pay attention to socket
/// destruction as well (eg, by using weak references), so that you do
/// not get fooled when the allocator reuses the memory address of a
/// previously-destroyed socket to represent a new socket.
///
/// # Returns
///
/// the #GSocket that @self is
/// associated with, [`None`] if you used [`ServerExt::accept_iostream()`][crate::prelude::ServerExt::accept_iostream()].
#[doc(alias = "soup_server_message_get_socket")]
#[doc(alias = "get_socket")]
pub fn socket(&self) -> Option<gio::Socket> {
unsafe { from_glib_none(ffi::soup_server_message_get_socket(self.to_glib_none().0)) }
}
/// Get the HTTP status code of @self.
///
/// # Returns
///
/// the HTTP status code.
#[doc(alias = "soup_server_message_get_status")]
#[doc(alias = "get_status")]
pub fn status(&self) -> u32 {
unsafe { ffi::soup_server_message_get_status(self.to_glib_none().0) }
}
/// Gets the peer's #GTlsCertificate associated with @self's connection.
/// Note that this is not set yet during the emission of
/// SoupServerMessage::accept-certificate signal.
///
/// # Returns
///
/// @self's TLS peer certificate,
/// or [`None`] if @self's connection is not SSL.
#[cfg(feature = "v3_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
#[doc(alias = "soup_server_message_get_tls_peer_certificate")]
#[doc(alias = "get_tls_peer_certificate")]
pub fn tls_peer_certificate(&self) -> Option<gio::TlsCertificate> {
unsafe {
from_glib_none(ffi::soup_server_message_get_tls_peer_certificate(
self.to_glib_none().0,
))
}
}
/// Gets the errors associated with validating @self's TLS peer certificate.
/// Note that this is not set yet during the emission of
/// SoupServerMessage::accept-certificate signal.
///
/// # Returns
///
/// a #GTlsCertificateFlags with @self's TLS peer certificate errors.
#[cfg(feature = "v3_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
#[doc(alias = "soup_server_message_get_tls_peer_certificate_errors")]
#[doc(alias = "get_tls_peer_certificate_errors")]
pub fn tls_peer_certificate_errors(&self) -> gio::TlsCertificateFlags {
unsafe {
from_glib(ffi::soup_server_message_get_tls_peer_certificate_errors(
self.to_glib_none().0,
))
}
}
/// Get @self's URI.
///
/// # Returns
///
/// a #GUri
#[doc(alias = "soup_server_message_get_uri")]
#[doc(alias = "get_uri")]
pub fn uri(&self) -> Option<glib::Uri> {
unsafe { from_glib_none(ffi::soup_server_message_get_uri(self.to_glib_none().0)) }
}
/// Gets if @self represents an OPTIONS message with the path `*`.
///
/// # Returns
///
/// [`true`] if is an OPTIONS ping
#[doc(alias = "soup_server_message_is_options_ping")]
pub fn is_options_ping(&self) -> bool {
unsafe {
from_glib(ffi::soup_server_message_is_options_ping(
self.to_glib_none().0,
))
}
}
/// Pauses I/O on @self.
///
/// This can be used when you need to return from the server handler without
/// having the full response ready yet. Use [`unpause()`][Self::unpause()] to
/// resume I/O.
#[cfg(feature = "v3_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
#[doc(alias = "soup_server_message_pause")]
pub fn pause(&self) {
unsafe {
ffi::soup_server_message_pause(self.to_glib_none().0);
}
}
/// Set the HTTP version of @self.
/// ## `version`
/// a #SoupHTTPVersion
#[doc(alias = "soup_server_message_set_http_version")]
pub fn set_http_version(&self, version: HTTPVersion) {
unsafe {
ffi::soup_server_message_set_http_version(self.to_glib_none().0, version.into_glib());
}
}
/// Sets @self's status_code to @status_code and adds a Location header
/// pointing to @redirect_uri. Use this from a [`Server`][crate::Server] when you
/// want to redirect the client to another URI.
///
/// @redirect_uri can be a relative URI, in which case it is
/// interpreted relative to @self's current URI. In particular, if
/// @redirect_uri is just a path, it will replace the path
/// *and query* of @self's URI.
/// ## `status_code`
/// a 3xx status code
/// ## `redirect_uri`
/// the URI to redirect @self to
#[doc(alias = "soup_server_message_set_redirect")]
pub fn set_redirect(&self, status_code: u32, redirect_uri: &str) {
unsafe {
ffi::soup_server_message_set_redirect(
self.to_glib_none().0,
status_code,
redirect_uri.to_glib_none().0,
);
}
}
/// Convenience function to set the response body of a #SoupServerMessage. If
/// @content_type is [`None`], the response body must be empty as well.
/// ## `content_type`
/// MIME Content-Type of the body
/// ## `resp_use`
/// a #SoupMemoryUse describing how to handle @resp_body
/// ## `resp_body`
///
/// a data buffer containing the body of the message response.
#[doc(alias = "soup_server_message_set_response")]
pub fn set_response(&self, content_type: Option<&str>, resp_use: MemoryUse, resp_body: &[u8]) {
let resp_length = resp_body.len() as _;
unsafe {
ffi::soup_server_message_set_response(
self.to_glib_none().0,
content_type.to_glib_none().0,
resp_use.into_glib(),
resp_body.to_glib_none().0,
resp_length,
);
}
}
/// Sets @self's status code to @status_code.
///
/// If @status_code is a known value and @reason_phrase is [`None`], the
/// reason_phrase will be set automatically.
/// ## `status_code`
/// an HTTP status code
/// ## `reason_phrase`
/// a reason phrase
#[doc(alias = "soup_server_message_set_status")]
pub fn set_status(&self, status_code: u32, reason_phrase: Option<&str>) {
unsafe {
ffi::soup_server_message_set_status(
self.to_glib_none().0,
status_code,
reason_phrase.to_glib_none().0,
);
}
}
/// "Steals" the HTTP connection associated with @self from its #SoupServer. This
/// happens immediately, regardless of the current state of the connection; if
/// the response to @self has not yet finished being sent, then it will be
/// discarded; you can steal the connection from a
/// [`wrote-informational`][struct@crate::ServerMessage#wrote-informational] or
/// [`wrote-body`][struct@crate::ServerMessage#wrote-body] signal handler if you need to wait for
/// part or all of the response to be sent.
///
/// Note that when calling this function from C, @self will most
/// likely be freed as a side effect.
///
/// # Returns
///
/// the #GIOStream formerly associated
/// with @self (or [`None`] if @self was no longer associated with a
/// connection). No guarantees are made about what kind of #GIOStream
/// is returned.
#[doc(alias = "soup_server_message_steal_connection")]
pub fn steal_connection(&self) -> Option<gio::IOStream> {
unsafe {
from_glib_full(ffi::soup_server_message_steal_connection(
self.to_glib_none().0,
))
}
}
/// Resumes I/O on @self.
///
/// Use this to resume after calling [`pause()`][Self::pause()], or after
/// adding a new chunk to a chunked response. I/O won't actually resume until you
/// return to the main loop.
#[cfg(feature = "v3_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
#[doc(alias = "soup_server_message_unpause")]
pub fn unpause(&self) {
unsafe {
ffi::soup_server_message_unpause(self.to_glib_none().0);
}
}
/// Emitted during the @msg's connection TLS handshake
/// after client TLS certificate has been received.
/// You can return [`true`] to accept @tls_certificate despite
/// @tls_errors.
/// ## `tls_peer_certificate`
/// the peer's #GTlsCertificate
/// ## `tls_peer_errors`
/// the tls errors of @tls_certificate
///
/// # Returns
///
/// [`true`] to accept the TLS certificate and stop other
/// handlers from being invoked, or [`false`] to propagate the
/// event further.
#[doc(alias = "accept-certificate")]
pub fn connect_accept_certificate<
F: Fn(&Self, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn accept_certificate_trampoline<
F: Fn(&ServerMessage, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
>(
this: *mut ffi::SoupServerMessage,
tls_peer_certificate: *mut gio::ffi::GTlsCertificate,
tls_peer_errors: gio::ffi::GTlsCertificateFlags,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
&from_glib_borrow(this),
&from_glib_borrow(tls_peer_certificate),
from_glib(tls_peer_errors),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"accept-certificate\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
accept_certificate_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the @msg's socket is connected and the TLS handshake completed.
#[doc(alias = "connected")]
pub fn connect_connected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn connected_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"connected\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
connected_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the @msg's socket is disconnected.
#[doc(alias = "disconnected")]
pub fn connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn disconnected_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"disconnected\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
disconnected_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when all HTTP processing is finished for a message.
/// (After [`wrote-body`][struct@crate::ServerMessage#wrote-body]).
#[doc(alias = "finished")]
pub fn connect_finished<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn finished_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"finished\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
finished_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted after receiving the complete request body.
#[doc(alias = "got-body")]
pub fn connect_got_body<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn got_body_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"got-body\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
got_body_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted after receiving a chunk of a message body.
///
/// Note that "chunk" in this context means any subpiece of the body, not
/// necessarily the specific HTTP 1.1 chunks sent by the other side.
/// ## `chunk`
/// the just-read chunk
#[doc(alias = "got-chunk")]
pub fn connect_got_chunk<F: Fn(&Self, &glib::Bytes) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn got_chunk_trampoline<F: Fn(&ServerMessage, &glib::Bytes) + 'static>(
this: *mut ffi::SoupServerMessage,
chunk: *mut glib::ffi::GBytes,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(chunk))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"got-chunk\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
got_chunk_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted after receiving the Request-Line and request headers.
#[doc(alias = "got-headers")]
pub fn connect_got_headers<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn got_headers_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"got-headers\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
got_headers_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted immediately after writing the complete response body for a
/// message.
#[doc(alias = "wrote-body")]
pub fn connect_wrote_body<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn wrote_body_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"wrote-body\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
wrote_body_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted immediately after writing a portion of the message
/// body to the network.
/// ## `chunk_size`
/// the number of bytes written
#[doc(alias = "wrote-body-data")]
pub fn connect_wrote_body_data<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn wrote_body_data_trampoline<F: Fn(&ServerMessage, u32) + 'static>(
this: *mut ffi::SoupServerMessage,
chunk_size: libc::c_uint,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), chunk_size)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"wrote-body-data\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
wrote_body_data_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted immediately after writing a body chunk for a message.
///
/// Note that this signal is not parallel to
/// [`got-chunk`][struct@crate::ServerMessage#got-chunk]; it is emitted only when a complete
/// chunk (added with `MessageBody::append()` or
/// [`MessageBody::append_bytes()`][crate::MessageBody::append_bytes()] has been written. To get
/// more useful continuous progress information, use
/// [`wrote-body-data`][struct@crate::ServerMessage#wrote-body-data].
#[doc(alias = "wrote-chunk")]
pub fn connect_wrote_chunk<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn wrote_chunk_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"wrote-chunk\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
wrote_chunk_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted immediately after writing the response headers for a
/// message.
#[doc(alias = "wrote-headers")]
pub fn connect_wrote_headers<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn wrote_headers_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"wrote-headers\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
wrote_headers_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted immediately after writing a 1xx (Informational) response.
#[doc(alias = "wrote-informational")]
pub fn connect_wrote_informational<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn wrote_informational_trampoline<F: Fn(&ServerMessage) + 'static>(
this: *mut ffi::SoupServerMessage,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"wrote-informational\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
wrote_informational_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v3_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
#[doc(alias = "tls-peer-certificate")]
pub fn connect_tls_peer_certificate_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_tls_peer_certificate_trampoline<
F: Fn(&ServerMessage) + 'static,
>(
this: *mut ffi::SoupServerMessage,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::tls-peer-certificate\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_tls_peer_certificate_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v3_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
#[doc(alias = "tls-peer-certificate-errors")]
pub fn connect_tls_peer_certificate_errors_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_tls_peer_certificate_errors_trampoline<
F: Fn(&ServerMessage) + 'static,
>(
this: *mut ffi::SoupServerMessage,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::tls-peer-certificate-errors\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_tls_peer_certificate_errors_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}