Represents an HTTP message being sent or received.
A [class@Message] represents an HTTP message that is being sent or received.
You would create a [class@Message] with [ctor@Message.new] or [ctor@Message.new_from_uri], set up its fields appropriately, and send it.
[property@Message:status-code] will normally be a [enum@Status] value, eg, soup_status_ok, though of
course it might actually be an unknown status code. [property@Message:reason-phrase] is the actual text returned from the server, which
may or may not correspond to the "standard" description of status_code. At any rate, it is almost certainly not localized,
and not very descriptive even if it is in the user's language; you should not use [property@Message:reason-phrase] in user-visible
messages. Rather, you should look at [property@Message:status-code], and determine an end-user-appropriate message based on that and on
what you were trying to do.
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 [class@Message] combines both the request and the response.
- public uint add_header_handler (string @signal, string header, Callback callback)
Adds a signal handler to this for
signal.
- public uint add_status_code_handler (string @signal, uint status_code, Callback callback)
Adds a signal handler to this for
signal.
- public void disable_feature (Type feature_type)
Disables the actions of [iface@SessionFeature]s with the given
feature_type (or a subclass of that type) on this.
- public unowned Address get_address ()
Gets the address this's URI points
to.
- public unowned URI get_first_party ()
Gets this's first-party [
struct@GLib.
- public MessageFlags get_flags ()
Gets the flags on this.
- public HTTPVersion get_http_version ()
Gets the HTTP version of this.
- public bool get_https_status (out unowned TlsCertificate certificate, out TlsCertificateFlags errors)
If this is using https (or attempted
to use https but got soup_status_ssl_failed), this retrieves the
TlsCertificate associated with its connection, and the
TlsCertificateFlags showing what problems, if any, have been found
with that certificate.
- public bool get_is_top_level_navigation ()
Returns if this message is set as a top level navigation.
- public MessagePriority get_priority ()
Retrieves the [enum@MessagePriority].
- public unowned URI get_site_for_cookies ()
Gets this's site for cookies
Uri.
- public unowned Request get_soup_request ()
If this is associated with a
Request, this returns that request.
- public unowned URI get_uri ()
Gets this's URI.
- public bool is_feature_disabled (Type feature_type)
Get whether [iface@SessionFeature]s of the given feature_type
(or a subclass of that type) are disabled on this.
- public bool is_keepalive ()
Determines whether or not this's
connection can be kept alive for further requests after processing this.
- public void set_chunk_allocator (owned ChunkAllocator allocator)
Sets an alternate chunk-allocation function to use when reading
this's body when using the traditional (ie, non-Request
<!-- -->-based) API.
- public void set_first_party (URI first_party)
Sets first_party as the main document
Uri for this.
- public void set_flags (MessageFlags flags)
Sets the specified flags on this.
- public void set_http_version (HTTPVersion version)
Sets the HTTP version on this.
- public void set_is_top_level_navigation (bool is_top_level_navigation)
Sets whether the current request is a top-level navitation.
- public void set_priority (MessagePriority priority)
Sets the priority of a message.
- public void set_redirect (uint status_code, string redirect_uri)
Sets this's status_code to
status_code and adds a Location header pointing to redirect_uri.
- public void set_request (string? content_type, MemoryUse req_use, uint8[] req_body)
Convenience function to set the request body of a
Message.
- public void set_response (string? content_type, MemoryUse resp_use, uint8[]? resp_body)
Convenience function to set the response body of a
Message.
- public void set_site_for_cookies (URI? site_for_cookies)
Sets site_for_cookies as the policy URL for same-site
cookies for this.
- public void set_status (uint status_code)
Sets this's status code to
status_code.
- public void set_status_full (uint status_code, string reason_phrase)
Sets this's status code and reason
phrase.
- public void set_uri (URI uri)
Sets this's URI to uri.
- public signal void content_sniffed (string content_type, HashTable<string,string> @params)
This signal is emitted after [signal@Message:
SoupMessage:got-headerss].
- public virtual signal void finished ()
Emitted when all HTTP processing is finished for a message.
- public virtual signal void got_body ()
Emitted after receiving the complete message response body.
- public virtual signal void got_chunk (Buffer chunk)
Emitted after receiving a chunk of a message body.
- public virtual signal void got_headers ()
Emitted after receiving the Status-Line and response headers.
- public virtual signal void got_informational ()
Emitted after receiving a 1xx (Informational) response for a (
client-side) message.
- public signal void network_event (SocketClientEvent event, IOStream connection)
Emitted to indicate that some network-related event related to
msg has occurred.
- public virtual signal void restarted ()
Emitted when a request that was already sent once is now being sent
again.
- public virtual signal void starting ()
Emitted just before a message is sent.
- public virtual signal void wrote_body ()
Emitted immediately after writing the complete body for a message.
- public signal void wrote_body_data (Buffer chunk)
Emitted immediately after writing a portion of the message body to the
network.
- public virtual signal void wrote_chunk ()
Emitted immediately after writing a body chunk for a message.
- public virtual signal void wrote_headers ()
Emitted immediately after writing the request headers for a message.
- public virtual signal void wrote_informational ()
Emitted immediately after writing a 1xx (Informational) response for a
(server-side) message.