:right-sidebar: True ServerMessage =================================================================== .. currentmodule:: gi.repository.Soup .. class:: ServerMessage(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: ServerMessage(**properties) Methods ------- .. rst-class:: interim-class .. class:: ServerMessage :no-index: .. method:: get_http_version() -> ~gi.repository.Soup.HTTPVersion Get the HTTP version of ``msg``. .. method:: get_local_address() -> ~gi.repository.Gio.SocketAddress | None Retrieves the :obj:`~gi.repository.Gio.SocketAddress` associated with the local end of a connection. .. method:: get_method() -> str Get the HTTP method of ``msg``. .. method:: get_reason_phrase() -> str | None Get the HTTP reason phrase of ``msg``. .. method:: get_remote_address() -> ~gi.repository.Gio.SocketAddress | None Retrieves the :obj:`~gi.repository.Gio.SocketAddress` associated with the remote end of a connection. .. method:: get_remote_host() -> str | None Retrieves the IP address associated with the remote end of a connection. .. method:: get_request_body() -> ~gi.repository.Soup.MessageBody Get the request body of ``msg``. .. method:: get_request_headers() -> ~gi.repository.Soup.MessageHeaders Get the request headers of ``msg``. .. method:: get_response_body() -> ~gi.repository.Soup.MessageBody Get the response body of ``msg``. .. method:: get_response_headers() -> ~gi.repository.Soup.MessageHeaders Get the response headers of ``msg``. .. method:: get_socket() -> ~gi.repository.Gio.Socket | None Retrieves the :obj:`~gi.repository.Gio.Socket` that ``msg`` 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. .. method:: get_status() -> int Get the HTTP status code of ``msg``. .. method:: get_tls_peer_certificate() -> ~gi.repository.Gio.TlsCertificate | None Gets the peer's :obj:`~gi.repository.Gio.TlsCertificate` associated with ``msg``'s connection. Note that this is not set yet during the emission of SoupServerMessage::accept-certificate signal. .. versionadded:: 3.2 .. method:: get_tls_peer_certificate_errors() -> ~gi.repository.Gio.TlsCertificateFlags Gets the errors associated with validating ``msg``'s TLS peer certificate. Note that this is not set yet during the emission of SoupServerMessage::accept-certificate signal. .. versionadded:: 3.2 .. method:: get_uri() -> ~gi.repository.GLib.Uri Get ``msg``'s URI. .. method:: is_options_ping() -> bool Gets if ``msg`` represents an OPTIONS message with the path ``*``. .. method:: pause() -> None Pauses I/O on ``msg``. This can be used when you need to return from the server handler without having the full response ready yet. Use :obj:`~gi.repository.ServerMessage.unpause` to resume I/O. .. versionadded:: 3.2 .. method:: set_http_version(version: ~gi.repository.Soup.HTTPVersion) -> None Set the HTTP version of ``msg``. :param version: a :obj:`~gi.repository.Soup.HTTPVersion` .. method:: set_redirect(status_code: int, redirect_uri: str) -> None Sets ``msg``'s status_code to ``status_code`` and adds a Location header pointing to ``redirect_uri``. Use this from a :obj:`~gi.repository.Soup.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 ``msg``'s current URI. In particular, if ``redirect_uri`` is just a path, it will replace the path *and query* of ``msg``'s URI. :param status_code: a 3xx status code :param redirect_uri: the URI to redirect ``msg`` to .. method:: set_response(content_type: str | None, resp_use: ~gi.repository.Soup.MemoryUse, resp_body: ~typing.Sequence[int] | None = None) -> None Convenience function to set the response body of a :obj:`~gi.repository.Soup.ServerMessage`. If ``content_type`` is :const:`None`, the response body must be empty as well. :param content_type: MIME Content-Type of the body :param resp_use: a :obj:`~gi.repository.Soup.MemoryUse` describing how to handle ``resp_body`` :param resp_body: a data buffer containing the body of the message response. .. method:: set_status(status_code: int, reason_phrase: str | None = None) -> None Sets ``msg``'s status code to ``status_code``. If ``status_code`` is a known value and ``reason_phrase`` is :const:`None`, the reason_phrase will be set automatically. :param status_code: an HTTP status code :param reason_phrase: a reason phrase .. method:: unpause() -> None Resumes I/O on ``msg``. Use this to resume after calling :obj:`~gi.repository.ServerMessage.pause`, or after adding a new chunk to a chunked response. I/O won't actually resume until you return to the main loop. .. versionadded:: 3.2 Properties ---------- .. rst-class:: interim-class .. class:: ServerMessage :no-index: .. attribute:: props.tls_peer_certificate :type: ~gi.repository.Gio.TlsCertificate The peer's :obj:`~gi.repository.Gio.TlsCertificate` associated with the message .. versionadded:: 3.2 .. attribute:: props.tls_peer_certificate_errors :type: ~gi.repository.Gio.TlsCertificateFlags The verification errors on :obj:`~gi.repository.Soup.ServerMessage`:tls-peer-certificate .. versionadded:: 3.2 Signals ------- .. rst-class:: interim-class .. class:: ServerMessage.signals :no-index: .. method:: accept_certificate(tls_peer_certificate: ~gi.repository.Gio.TlsCertificate, tls_peer_errors: ~gi.repository.Gio.TlsCertificateFlags) -> bool Emitted during the ``msg``'s connection TLS handshake after client TLS certificate has been received. You can return :const:`True` to accept ``tls_certificate`` despite ``tls_errors``. :param tls_peer_certificate: the peer's :obj:`~gi.repository.Gio.TlsCertificate` :param tls_peer_errors: the tls errors of ``tls_certificate`` .. method:: connected() -> None Emitted when the ``msg``'s socket is connected and the TLS handshake completed. .. method:: disconnected() -> None Emitted when the ``msg``'s socket is disconnected. .. method:: finished() -> None Emitted when all HTTP processing is finished for a message. (After :obj:`~gi.repository.Soup.ServerMessage.signals.wrote_body`). .. method:: got_body() -> None Emitted after receiving the complete request body. .. method:: got_chunk(chunk: ~gi.repository.GLib.Bytes) -> None 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. :param chunk: the just-read chunk .. method:: got_headers() -> None Emitted after receiving the Request-Line and request headers. .. method:: wrote_body() -> None Emitted immediately after writing the complete response body for a message. .. method:: wrote_body_data(chunk_size: int) -> None Emitted immediately after writing a portion of the message body to the network. :param chunk_size: the number of bytes written .. method:: wrote_chunk() -> None Emitted immediately after writing a body chunk for a message. Note that this signal is not parallel to :obj:`~gi.repository.Soup.ServerMessage.signals.got_chunk`; it is emitted only when a complete chunk (added with :obj:`~gi.repository.MessageBody.append` or :obj:`~gi.repository.MessageBody.append_bytes` has been written. To get more useful continuous progress information, use :obj:`~gi.repository.Soup.ServerMessage.signals.wrote_body_data`. .. method:: wrote_headers() -> None Emitted immediately after writing the response headers for a message. .. method:: wrote_informational() -> None Emitted immediately after writing a 1xx (Informational) response.