/usr/share/gir-1.0/Uhm-0.0.gir is in libuhttpmock-dev 0.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 | <?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GObject" version="2.0"/>
<include name="Soup" version="2.4"/>
<package name="libuhttpmock"/>
<c:include name="libuhttpmock/uhm.h"/>
<namespace name="Uhm"
version="0.0"
shared-library="libuhttpmock-0.0.so.0"
c:identifier-prefixes="Uhm"
c:symbol-prefixes="uhm">
<constant name="MAJOR_VERSION"
value="0"
c:type="UHM_MAJOR_VERSION"
version="0.1.0">
<doc xml:space="preserve">Evaluates to the major version of the libuhttpmock headers at compile time.
(e.g. in libuhttpmock version 1.2.3 this is 1).</doc>
<type name="gint" c:type="gint"/>
</constant>
<constant name="MICRO_VERSION"
value="1"
c:type="UHM_MICRO_VERSION"
version="0.1.0">
<doc xml:space="preserve">Evaluates to the micro version of the libuhttpmock headers at compile time.
(e.g. in libuhttpmock version 1.2.3 this is 3).</doc>
<type name="gint" c:type="gint"/>
</constant>
<constant name="MINOR_VERSION"
value="3"
c:type="UHM_MINOR_VERSION"
version="0.1.0">
<doc xml:space="preserve">Evaluates to the minor version of the libuhttpmock headers at compile time.
(e.g. in libuhttpmock version 1.2.3 this is 2).</doc>
<type name="gint" c:type="gint"/>
</constant>
<class name="Resolver"
c:symbol-prefix="resolver"
c:type="UhmResolver"
version="0.1.0"
parent="Gio.Resolver"
glib:type-name="UhmResolver"
glib:get-type="uhm_resolver_get_type"
glib:type-struct="ResolverClass">
<doc xml:space="preserve">All the fields in the #UhmResolver structure are private and should never be accessed directly.</doc>
<constructor name="new" c:identifier="uhm_resolver_new">
<doc xml:space="preserve">Creates a new #UhmResolver with default property values.</doc>
<return-value transfer-ownership="full">
<doc xml:space="preserve">a new #UhmResolver; unref with g_object_unref()</doc>
<type name="Resolver" c:type="UhmResolver*"/>
</return-value>
</constructor>
<method name="add_A" c:identifier="uhm_resolver_add_A" version="0.1.0">
<doc xml:space="preserve">Adds a resolution mapping from the host name @hostname to the IP address @addr.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">%TRUE on success; %FALSE otherwise</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmResolver</doc>
<type name="Resolver" c:type="UhmResolver*"/>
</instance-parameter>
<parameter name="hostname" transfer-ownership="none">
<doc xml:space="preserve">the hostname to match</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="addr" transfer-ownership="none">
<doc xml:space="preserve">the IP address to resolve to</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</method>
<method name="add_SRV"
c:identifier="uhm_resolver_add_SRV"
version="0.1.0">
<doc xml:space="preserve">Adds a resolution mapping the given @service (on @protocol and @domain) to the IP address @addr and given @port.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">%TRUE on success; %FALSE otherwise</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmResolver</doc>
<type name="Resolver" c:type="UhmResolver*"/>
</instance-parameter>
<parameter name="service" transfer-ownership="none">
<doc xml:space="preserve">the service name to match</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="protocol" transfer-ownership="none">
<doc xml:space="preserve">the protocol name to match</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="domain" transfer-ownership="none">
<doc xml:space="preserve">the domain name to match</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="addr" transfer-ownership="none">
<doc xml:space="preserve">the IP address to resolve to</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="port" transfer-ownership="none">
<doc xml:space="preserve">the port to resolve to</doc>
<type name="guint16" c:type="guint16"/>
</parameter>
</parameters>
</method>
<method name="reset" c:identifier="uhm_resolver_reset">
<doc xml:space="preserve">Resets the state of the #UhmResolver, deleting all records added with uhm_resolver_add_A() and uhm_resolver_add_SRV().</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmResolver</doc>
<type name="Resolver" c:type="UhmResolver*"/>
</instance-parameter>
</parameters>
</method>
<field name="parent" readable="0" private="1">
<type name="Gio.Resolver" c:type="GResolver"/>
</field>
<field name="priv" readable="0" private="1">
<type name="ResolverPrivate" c:type="UhmResolverPrivate*"/>
</field>
</class>
<record name="ResolverClass"
c:type="UhmResolverClass"
glib:is-gtype-struct-for="Resolver"
version="0.1.0">
<doc xml:space="preserve">All the fields in the #UhmResolverClass structure are private and should never be accessed directly.</doc>
<field name="parent" readable="0" private="1">
<type name="Gio.ResolverClass" c:type="GResolverClass"/>
</field>
</record>
<record name="ResolverPrivate" c:type="UhmResolverPrivate" disguised="1">
</record>
<class name="Server"
c:symbol-prefix="server"
c:type="UhmServer"
version="0.1.0"
parent="GObject.Object"
glib:type-name="UhmServer"
glib:get-type="uhm_server_get_type"
glib:type-struct="ServerClass">
<doc xml:space="preserve">All the fields in the #UhmServer structure are private and should never be accessed directly.</doc>
<constructor name="new" c:identifier="uhm_server_new" version="0.1.0">
<doc xml:space="preserve">Creates a new #UhmServer with default properties.</doc>
<return-value transfer-ownership="full">
<doc xml:space="preserve">a new #UhmServer; unref with g_object_unref()</doc>
<type name="Server" c:type="UhmServer*"/>
</return-value>
</constructor>
<function name="error_quark" c:identifier="uhm_server_error_quark">
<return-value transfer-ownership="none">
<type name="GLib.Quark" c:type="GQuark"/>
</return-value>
</function>
<function name="received_message_chunk_from_soup"
c:identifier="uhm_server_received_message_chunk_from_soup"
version="0.3.0">
<doc xml:space="preserve">Convenience version of uhm_server_received_message_chunk() which can be passed directly to soup_logger_set_printer()
to forward all libsoup traffic logging to a #UhmServer. The #UhmServer must be passed to soup_logger_set_printer() as
its user data.
<informalexample><programlisting>
UhmServer *mock_server;
SoupSession *session;
SoupLogger *logger;
mock_server = uhm_server_new ();
session = soup_session_new ();
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
soup_logger_set_printer (logger, uhm_server_received_message_chunk_from_soup, g_object_ref (mock_server), g_object_unref);
soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
g_object_unref (logger);
/<!-- -->* Do something with mock_server here. *<!-- -->/
</programlisting></informalexample></doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="logger" transfer-ownership="none">
<doc xml:space="preserve">a #SoupLogger</doc>
<type name="Soup.Logger" c:type="SoupLogger*"/>
</parameter>
<parameter name="level" transfer-ownership="none">
<doc xml:space="preserve">the detail level of this log message</doc>
<type name="Soup.LoggerLogLevel" c:type="SoupLoggerLogLevel"/>
</parameter>
<parameter name="direction" transfer-ownership="none">
<doc xml:space="preserve">the transmission direction of the message</doc>
<type name="gchar" c:type="char"/>
</parameter>
<parameter name="data" transfer-ownership="none">
<doc xml:space="preserve">message data</doc>
<type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="user_data" transfer-ownership="none" allow-none="1">
<doc xml:space="preserve">user data passed to the #SoupLogger, or %NULL</doc>
<type name="gpointer" c:type="gpointer"/>
</parameter>
</parameters>
</function>
<virtual-method name="compare_messages">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="expected_message" transfer-ownership="none">
<type name="Soup.Message" c:type="SoupMessage*"/>
</parameter>
<parameter name="actual_message" transfer-ownership="none">
<type name="Soup.Message" c:type="SoupMessage*"/>
</parameter>
<parameter name="actual_client" transfer-ownership="none">
<type name="Soup.ClientContext" c:type="SoupClientContext*"/>
</parameter>
</parameters>
</virtual-method>
<virtual-method name="handle_message">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="message" transfer-ownership="none">
<type name="Soup.Message" c:type="SoupMessage*"/>
</parameter>
<parameter name="client" transfer-ownership="none">
<type name="Soup.ClientContext" c:type="SoupClientContext*"/>
</parameter>
</parameters>
</virtual-method>
<method name="end_trace"
c:identifier="uhm_server_end_trace"
version="0.1.0">
<doc xml:space="preserve">Convenience function to finish logging to or reading from a trace file previously passed to uhm_server_start_trace() or
uhm_server_start_trace_full().
If #UhmServer:enable-online is %FALSE, this will shut down the mock server (as if uhm_server_stop() had been called).</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_address"
c:identifier="uhm_server_get_address"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:address property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">the physical address of the listening socket the server is currently bound to; or %NULL if the server is not running</doc>
<type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_enable_logging"
c:identifier="uhm_server_get_enable_logging"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:enable-logging property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">%TRUE if client network traffic is being logged to a trace file; %FALSE otherwise</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_enable_online"
c:identifier="uhm_server_get_enable_online"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:enable-online property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">%TRUE if the server does not intercept and handle network connections from client code; %FALSE otherwise</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_port"
c:identifier="uhm_server_get_port"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:port property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">the port of the listening socket the server is currently bound to; or <code class="literal">0</code> if the server is not running</doc>
<type name="guint" c:type="guint"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_resolver"
c:identifier="uhm_server_get_resolver"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:resolver property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">the mock resolver in use by the mock server, or %NULL if no resolver is active</doc>
<type name="Resolver" c:type="UhmResolver*"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_tls_certificate"
c:identifier="uhm_server_get_tls_certificate"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:tls-certificate property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">the server's current TLS certificate; or %NULL if it's serving HTTP only</doc>
<type name="Gio.TlsCertificate" c:type="GTlsCertificate*"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_trace_directory"
c:identifier="uhm_server_get_trace_directory"
version="0.1.0">
<doc xml:space="preserve">Gets the value of the #UhmServer:trace-directory property.</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">the directory to load/store trace files from, or %NULL</doc>
<type name="Gio.File" c:type="GFile*"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="load_trace"
c:identifier="uhm_server_load_trace"
version="0.1.0"
throws="1">
<doc xml:space="preserve">Synchronously loads the given @trace_file of network messages, ready to simulate a network conversation by matching
requests against the file and returning the associated responses. Call uhm_server_run() to start the mock
server afterwards.
Loading the trace file may be cancelled from another thread using @cancellable.
On error, @error will be set and the state of the #UhmServer will not change. A #GIOError will be set if there is
a problem reading the trace file.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="trace_file" transfer-ownership="none">
<doc xml:space="preserve">trace file to load</doc>
<type name="Gio.File" c:type="GFile*"/>
</parameter>
<parameter name="cancellable"
transfer-ownership="none"
allow-none="1">
<doc xml:space="preserve">a #GCancellable, or %NULL</doc>
<type name="Gio.Cancellable" c:type="GCancellable*"/>
</parameter>
</parameters>
</method>
<method name="load_trace_async"
c:identifier="uhm_server_load_trace_async"
version="0.1.0">
<doc xml:space="preserve">Asynchronous version of uhm_server_load_trace(). In @callback, call uhm_server_load_trace_finish() to complete the operation.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="trace_file" transfer-ownership="none">
<doc xml:space="preserve">trace file to load</doc>
<type name="Gio.File" c:type="GFile*"/>
</parameter>
<parameter name="cancellable"
transfer-ownership="none"
allow-none="1">
<doc xml:space="preserve">a #GCancellable, or %NULL</doc>
<type name="Gio.Cancellable" c:type="GCancellable*"/>
</parameter>
<parameter name="callback"
transfer-ownership="none"
allow-none="1"
scope="async"
closure="3">
<doc xml:space="preserve">function to call once the async operation is complete</doc>
<type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
</parameter>
<parameter name="user_data" transfer-ownership="none" allow-none="1">
<doc xml:space="preserve">user data to pass to @callback, or %NULL</doc>
<type name="gpointer" c:type="gpointer"/>
</parameter>
</parameters>
</method>
<method name="load_trace_finish"
c:identifier="uhm_server_load_trace_finish"
version="0.1.0"
throws="1">
<doc xml:space="preserve">Finishes an asynchronous operation started by uhm_server_load_trace_async().
On error, @error will be set and the state of the #UhmServer will not change.
See uhm_server_load_trace() for details on the error domains used.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="result" transfer-ownership="none">
<doc xml:space="preserve">asynchronous operation result passed to the callback</doc>
<type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
</parameter>
</parameters>
</method>
<method name="received_message_chunk"
c:identifier="uhm_server_received_message_chunk"
version="0.1.0"
throws="1">
<doc xml:space="preserve">Indicates to the mock server that a single new line of a message was received from the real server. The message line may be
appended to the current trace file if logging is enabled (#UhmServer:enable-logging is %TRUE), adding a newline character
at the end. If logging is disabled but online mode is enabled (#UhmServer:enable-online is %TRUE), the message line will
be compared to the next expected line in the existing trace file. Otherwise, this function is a no-op.
On failure, @error will be set and the #UhmServer state will remain unchanged apart from the parse state machine, which will remain
in the state reached after parsing @message_chunk. A %G_IO_ERROR will be returned if writing to the trace file failed. If in
comparison mode and the received message chunk corresponds to an unexpected message in the trace file, a %UHM_SERVER_ERROR will
be returned.
<note><para>In common cases where message log data only needs to be passed to a #UhmServer and not (for example) logged to an
application-specific file or the command line as well, it is simpler to use uhm_server_received_message_chunk_from_soup(), passing
it directly to soup_logger_set_printer(). See the documentation for uhm_server_received_message_chunk_from_soup() for details.</para></note></doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="message_chunk" transfer-ownership="none">
<doc xml:space="preserve">single line of a message which was received</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="message_chunk_length" transfer-ownership="none">
<doc xml:space="preserve">length of @message_chunk in bytes</doc>
<type name="gint64" c:type="goffset"/>
</parameter>
</parameters>
</method>
<method name="received_message_chunk_with_direction"
c:identifier="uhm_server_received_message_chunk_with_direction"
version="0.3.0"
throws="1">
<doc xml:space="preserve">Convenience version of uhm_server_received_message_chunk() which takes the
message @direction and @data separately, as provided by libsoup in a
#SoupLoggerPrinter callback.
<informalexample><programlisting>
UhmServer *mock_server;
SoupSession *session;
SoupLogger *logger;
static void
soup_log_printer (SoupLogger *logger, SoupLoggerLogLevel level, char direction, const char *data, gpointer user_data)
{
/<!-- -->* Pass the data to libuhttpmock. *<!-- -->/
UhmServer *mock_server = UHM_SERVER (user_data);
uhm_server_received_message_chunk_with_direction (mock_server, direction, data, strlen (data), NULL);
}
mock_server = uhm_server_new ();
session = soup_session_new ();
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
soup_logger_set_printer (logger, (SoupLoggerPrinter) soup_log_printer, g_object_ref (mock_server), g_object_unref);
soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
g_object_unref (logger);
/<!-- -->* Do something with mock_server here. *<!-- -->/
</programlisting></informalexample></doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="direction" transfer-ownership="none">
<doc xml:space="preserve">single character indicating the direction of message transmission</doc>
<type name="gchar" c:type="char"/>
</parameter>
<parameter name="data" transfer-ownership="none">
<doc xml:space="preserve">single line of a message which was received</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="data_length" transfer-ownership="none">
<doc xml:space="preserve">length of @data in bytes</doc>
<type name="gint64" c:type="goffset"/>
</parameter>
</parameters>
</method>
<method name="run" c:identifier="uhm_server_run" version="0.1.0">
<doc xml:space="preserve">Runs the mock server, binding to a loopback TCP/IP interface and preparing a HTTPS server which is ready to accept requests.
The TCP/IP address and port number are chosen randomly out of the loopback addresses, and are exposed as #UhmServer:address and #UhmServer:port
once this function has returned. A #UhmResolver (exposed as #UhmServer:resolver) is set as the default #GResolver while the server is running.
The server is started in a worker thread, so this function returns immediately and the server continues to run in the background. Use uhm_server_stop()
to shut it down.
This function always succeeds.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="set_default_tls_certificate"
c:identifier="uhm_server_set_default_tls_certificate"
version="0.1.0">
<doc xml:space="preserve">Sets the value of the #UhmServer:tls-certificate property to the default TLS certificate built in to libuhttpmock.
This default certificate is not signed by any certificate authority, and contains minimal metadata details. It may
be used by clients which have no special certificate requirements; clients which have special requirements should
construct a custom #GTlsCertificate and pass it to uhm_server_set_tls_certificate().</doc>
<return-value transfer-ownership="none">
<doc xml:space="preserve">the default certificate set as #UhmServer:tls-certificate</doc>
<type name="Gio.TlsCertificate" c:type="GTlsCertificate*"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="set_enable_logging"
c:identifier="uhm_server_set_enable_logging"
version="0.1.0">
<doc xml:space="preserve">Sets the value of the #UhmServer:enable-logging property.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="enable_logging" transfer-ownership="none">
<doc xml:space="preserve">%TRUE to log client network traffic to a trace file; %FALSE otherwise</doc>
<type name="gboolean" c:type="gboolean"/>
</parameter>
</parameters>
</method>
<method name="set_enable_online"
c:identifier="uhm_server_set_enable_online"
version="0.1.0">
<doc xml:space="preserve">Sets the value of the #UhmServer:enable-online property.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="enable_online" transfer-ownership="none">
<doc xml:space="preserve">%TRUE to not intercept and handle network connections from client code; %FALSE otherwise</doc>
<type name="gboolean" c:type="gboolean"/>
</parameter>
</parameters>
</method>
<method name="set_expected_domain_names"
c:identifier="uhm_server_set_expected_domain_names"
version="0.3.0">
<doc xml:space="preserve">Set the domain names which are expected to have requests made of them by the client code interacting with this #UhmServer.
This is a convenience method which calls uhm_resolver_add_A() on the server’s #UhmResolver for each of the domain names
listed in @domain_names. It associates them with the server’s current IP address, and automatically updates the mappings
if the IP address or resolver change.
Note that this will reset all records on the server’s #UhmResolver, replacing all of them with the provided @domain_names.
It is safe to add further domain names to the #UhmResolver in a callback for the #GObject::notify signal for #UhmServer:resolver;
that signal is emitted after the resolver is cleared and these @domain_names are added.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="domain_names"
transfer-ownership="none"
allow-none="1">
<doc xml:space="preserve">%NULL-terminated array of domain names to expect, or %NULL to not expect any</doc>
<array c:type="gchar**">
<type name="utf8"/>
</array>
</parameter>
</parameters>
</method>
<method name="set_tls_certificate"
c:identifier="uhm_server_set_tls_certificate"
version="0.1.0">
<doc xml:space="preserve">Sets the value of the #UhmServer:tls-certificate property.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="tls_certificate"
transfer-ownership="none"
allow-none="1">
<doc xml:space="preserve">TLS certificate for the server to use; or %NULL to serve HTTP only</doc>
<type name="Gio.TlsCertificate" c:type="GTlsCertificate*"/>
</parameter>
</parameters>
</method>
<method name="set_trace_directory"
c:identifier="uhm_server_set_trace_directory"
version="0.1.0">
<doc xml:space="preserve">Sets the value of the #UhmServer:trace-directory property.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="trace_directory"
transfer-ownership="none"
allow-none="1">
<doc xml:space="preserve">a directory to load/store trace files from, or %NULL to unset it</doc>
<type name="Gio.File" c:type="GFile*"/>
</parameter>
</parameters>
</method>
<method name="start_trace"
c:identifier="uhm_server_start_trace"
version="0.1.0"
throws="1">
<doc xml:space="preserve">Starts a mock server which follows the trace file of filename @trace_name in the #UhmServer:trace-directory directory.
See uhm_server_start_trace_full() for further documentation.
This function has undefined behaviour if #UhmServer:trace-directory is %NULL.
On failure, @error will be set and the #UhmServer state will remain unchanged. See uhm_server_start_trace_full() for
details of the error domains used.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="trace_name" transfer-ownership="none">
<doc xml:space="preserve">name of the trace</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</method>
<method name="start_trace_full"
c:identifier="uhm_server_start_trace_full"
version="0.1.0"
throws="1">
<doc xml:space="preserve">Convenience function to start logging to or reading from the given @trace_file, depending on the values of #UhmServer:enable-logging and
#UhmServer:enable-online.
If #UhmServer:enable-logging is %TRUE, a log handler will be set up to redirect all client network activity into the given @trace_file.
If @trace_file already exists, it will be overwritten.
If #UhmServer:enable-online is %FALSE, the given @trace_file is loaded using uhm_server_load_trace() and then a mock server is
started using uhm_server_run().
On failure, @error will be set and the #UhmServer state will remain unchanged. A #GIOError will be set if logging is enabled
(#UhmServer:enable-logging) and there is a problem writing to the trace file; or if a trace needs to be loaded and there is a problem
reading from the trace file.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
<parameter name="trace_file" transfer-ownership="none">
<doc xml:space="preserve">a trace file to load</doc>
<type name="Gio.File" c:type="GFile*"/>
</parameter>
</parameters>
</method>
<method name="stop" c:identifier="uhm_server_stop" version="0.1.0">
<doc xml:space="preserve">Stops a mock server started by calling uhm_server_run(). This shuts down the server's worker thread and unbinds it from its TCP/IP socket.
This unloads any trace file loaded by calling uhm_server_load_trace() (or its asynchronous counterpart). It also resets the set of domain
names loaded into the #UhmServer:resolver.
This function always succeeds.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<method name="unload_trace"
c:identifier="uhm_server_unload_trace"
version="0.1.0">
<doc xml:space="preserve">Unloads the current trace file of network messages, as loaded by uhm_server_load_trace() or uhm_server_load_trace_async().</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">a #UhmServer</doc>
<type name="Server" c:type="UhmServer*"/>
</instance-parameter>
</parameters>
</method>
<property name="address" version="0.1.0" transfer-ownership="none">
<doc xml:space="preserve">Address of the local mock server if it's running, or %NULL otherwise. This will be non-%NULL between calls to uhm_server_run() and
uhm_server_stop(). The address is a physical IP address, e.g. <code class="literal">127.0.0.1</code>.
This should not normally need to be passed into client code under test, unless the code references IP addresses specifically. The mock server
runs a DNS resolver which automatically redirects client requests for known domain names to this address (#UhmServer:resolver).</doc>
<type name="utf8" c:type="gchar*"/>
</property>
<property name="enable-logging"
version="0.1.0"
writable="1"
transfer-ownership="none">
<doc xml:space="preserve">%TRUE if network traffic should be logged to a trace file (specified by calling uhm_server_start_trace()). This operates independently
of whether traffic is online or being handled locally by the mock server.
Use this in conjunction with #UhmServer:enable-online to either log online traffic, or replay logged traffic locally.</doc>
<type name="gboolean" c:type="gboolean"/>
</property>
<property name="enable-online"
version="0.1.0"
writable="1"
transfer-ownership="none">
<doc xml:space="preserve">%TRUE if network traffic should reach the Internet as normal; %FALSE to redirect it to the local mock server.
Use this in conjunction with #UhmServer:enable-logging to either log online traffic, or replay logged traffic locally.</doc>
<type name="gboolean" c:type="gboolean"/>
</property>
<property name="port" version="0.1.0" transfer-ownership="none">
<doc xml:space="preserve">Port of the local mock server if it's running, or <code class="literal">0</code> otherwise. This will be non-<code class="literal">0</code> between
calls to uhm_server_run() and uhm_server_stop().
It is intended that this port be passed into the client code under test, to substitute for the default HTTPS port (443) which it would otherwise
use.</doc>
<type name="guint" c:type="guint"/>
</property>
<property name="resolver" version="0.1.0" transfer-ownership="none">
<doc xml:space="preserve">Mock resolver used to redirect HTTP requests from specified domain names to the local mock server instance. This will always be set while the
server is running (between calls to uhm_server_run() and uhm_server_stop()), and is %NULL otherwise.
Use the resolver specified in this property to add domain names which are expected to be requested by the current trace. Domain names not added
to the resolver will be rejected by the mock server. The set of domain names in the resolver will be reset when uhm_server_stop() is
called.</doc>
<type name="Resolver"/>
</property>
<property name="tls-certificate"
version="0.1.0"
writable="1"
transfer-ownership="none">
<doc xml:space="preserve">TLS certificate for the mock server to use when serving HTTPS pages. If this is non-%NULL, the server will always use HTTPS. If it is %NULL,
the server will always use HTTP. The TLS certificate may be changed after constructing the #UhmServer, but changes to the property will not
take effect until the next call to uhm_server_run().
A certificate and private key may be generated by executing:
<code>openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -nodes</code>. These files may then be used to construct a
#GTlsCertificate by calling g_tls_certificate_new_from_files().
Alternatively, a default #GTlsCertificate which wraps a dummy certificate (not signed by any certificate authority) may be set by
calling uhm_server_set_default_tls_certificate(). This may be used as the #UhmServer:tls-certificate if the code under test has no specific
requirements of the certificate used by the mock server it's tested against.</doc>
<type name="Gio.TlsCertificate"/>
</property>
<property name="trace-directory"
version="0.1.0"
writable="1"
transfer-ownership="none">
<doc xml:space="preserve">Directory relative to which all trace files specified in calls to uhm_server_start_trace() will be resolved.
This is not used for any other methods, but must be non-%NULL if uhm_server_start_trace() is called.</doc>
<type name="Gio.File"/>
</property>
<field name="parent" readable="0" private="1">
<type name="GObject.Object" c:type="GObject"/>
</field>
<field name="priv" readable="0" private="1">
<type name="ServerPrivate" c:type="UhmServerPrivate*"/>
</field>
<glib:signal name="compare-messages" when="last" version="0.1.0">
<doc xml:space="preserve">Emitted whenever the mock server must compare two #SoupMessage<!-- -->s for equality; e.g. when in the testing or comparison modes.
Test code may connect to this signal and implement a handler which checks custom properties of the messages. The default handler compares
the URI and method of the messages, but no headers and not the message bodies.
Signal handlers should return %TRUE if the messages match; and %FALSE otherwise. The first signal handler executed when
this signal is emitted wins.</doc>
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="expected_message" transfer-ownership="none">
<doc xml:space="preserve">a message containing the expected HTTP(S) message provided by #UhmServer::handle-message</doc>
<type name="Soup.Message"/>
</parameter>
<parameter name="actual_message" transfer-ownership="none">
<doc xml:space="preserve">a message containing the incoming HTTP(S) request</doc>
<type name="Soup.Message"/>
</parameter>
<parameter name="actual_client" transfer-ownership="none">
<doc xml:space="preserve">additional data about the HTTP client making the request</doc>
<type name="Soup.ClientContext"/>
</parameter>
</parameters>
</glib:signal>
<glib:signal name="handle-message" when="last" version="0.1.0">
<doc xml:space="preserve">Emitted whenever the mock server is running and receives a request from a client. Test code may connect to this signal and implement a handler
which builds and returns a suitable response for a given message. The default handler reads a request–response pair from the current trace file,
matches the requests and then returns the given response. If the requests don't match, an error is raised.
Signal handlers should return %TRUE if they have handled the request and set an appropriate response; and %FALSE otherwise.</doc>
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="message" transfer-ownership="none">
<doc xml:space="preserve">a message containing the incoming HTTP(S) request, and which the outgoing HTTP(S) response should be set on</doc>
<type name="Soup.Message"/>
</parameter>
<parameter name="client" transfer-ownership="none">
<doc xml:space="preserve">additional data about the HTTP client making the request</doc>
<type name="Soup.ClientContext"/>
</parameter>
</parameters>
</glib:signal>
</class>
<record name="ServerClass"
c:type="UhmServerClass"
glib:is-gtype-struct-for="Server"
version="0.1.0">
<doc xml:space="preserve">Most of the fields in the #UhmServerClass structure are private and should never be accessed directly.</doc>
<field name="parent" readable="0" private="1">
<type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
<field name="handle_message">
<callback name="handle_message">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="self" transfer-ownership="none">
<type name="Server" c:type="UhmServer*"/>
</parameter>
<parameter name="message" transfer-ownership="none">
<type name="Soup.Message" c:type="SoupMessage*"/>
</parameter>
<parameter name="client" transfer-ownership="none">
<type name="Soup.ClientContext" c:type="SoupClientContext*"/>
</parameter>
</parameters>
</callback>
</field>
<field name="compare_messages">
<callback name="compare_messages">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="self" transfer-ownership="none">
<type name="Server" c:type="UhmServer*"/>
</parameter>
<parameter name="expected_message" transfer-ownership="none">
<type name="Soup.Message" c:type="SoupMessage*"/>
</parameter>
<parameter name="actual_message" transfer-ownership="none">
<type name="Soup.Message" c:type="SoupMessage*"/>
</parameter>
<parameter name="actual_client" transfer-ownership="none">
<type name="Soup.ClientContext" c:type="SoupClientContext*"/>
</parameter>
</parameters>
</callback>
</field>
</record>
<enumeration name="ServerError" c:type="UhmServerError">
<doc xml:space="preserve">Error codes for #UhmServer operations.</doc>
<member name="server_error_message_mismatch"
value="1"
c:identifier="UHM_SERVER_ERROR_MESSAGE_MISMATCH">
<doc xml:space="preserve">In comparison mode, a message received from the client did not match the next message in the current trace file.</doc>
</member>
</enumeration>
<record name="ServerPrivate" c:type="UhmServerPrivate" disguised="1">
</record>
</namespace>
</repository>
|