It derives from <GObject>.
Represents an HTTP message being sent or received.
A Message represents an HTTP message that is being sent or
received.
You would create a Message with Message.new or
Message.new_from_uri, set up its fields appropriately, and send
it.
Message:status-code will normally be a Status value, eg,
ok, though of course it might actually be an
unknown status code. 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 Message:reason-phrase in
user-visible messages. Rather, you should look at
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 Message combines
both the request and the response.
The <GUri> loaded in the application when the
message was queued.
Its value is a <GUri>, or #f.
Set it with (set! (message:first-party self) value).
Various message options.
Its value is a <SoupMessageFlags> (or, to set
it, a list of its symbols, or one of them).
Set it with (set! (message:flags self) value).
The HTTP protocol version to use.
Its value is a <SoupHTTPVersion>.
It is read only.
Whether the message is an OPTIONS ping.
The Message is intended to be used to send OPTIONS * to a
server. When set to #t, the path of Message:uri will be
ignored and Message:method set to SOUP_METHOD_OPTIONS.
Its value is a boolean.
Set it with (set! (message:is-options-ping self) value).
Set when the message is navigating between top level domains.
Its value is a boolean.
Set it with (set! (message:is-top-level-navigation self) value).
The message’s HTTP method.
Its value is a string, or #f.
Set it with (set! (message:method self) value).
Sets the priority of the Message. See
Message.set_priority for further details.
Its value is a <SoupMessagePriority> (or,
to set it, one of its symbols).
Set it with (set! (message:priority self) value).
The HTTP response reason phrase.
Its value is a string, or #f.
It is read only.
The remote <GSocketAddress> of the
connection associated with the message.
Its value is a <GSocketAddress>, or
#f.
It is read only.
The HTTP request headers.
Its value is a <SoupMessageHeaders>, or
#f.
It is read only.
The HTTP response headers.
Its value is a <SoupMessageHeaders>, or
#f.
It is read only.
Site used to compare cookies against. Used for SameSite cookie support.
Its value is a <GUri>, or #f.
Set it with (set! (message:site-for-cookies self) value).
The HTTP response status code.
Its value is an unsigned 32-bit integer.
It is read only.
The Name of TLS ciphersuite negotiated for this message connection.
Its value is a string, or #f.
It is read only.
The peer’s <GTlsCertificate> associated
with the message.
Its value is a <GTlsCertificate>, or
#f.
It is read only.
The verification errors on Message:tls-peer-certificate.
Its value is a
<GTlsCertificateFlags>.
It is read only.
The TLS protocol version negotiated for the message connection.
Its value is a
<GTlsProtocolVersion>.
It is read only.
The message’s Request-URI.
Its value is a <GUri>, or #f.
Set it with (set! (message:uri self) value).
Adds flags to the set of self’s flags.
Passed: a <SoupMessage>.
Passed: a <SoupMessageFlags>, or a list of
its symbols, or one of them.
a set of <SoupMessageFlags> values
Disables the actions of SessionFeatures with the given
feature-type (or a subclass of that type) on self.
self is processed as though the feature(s) hadn’t been added to
the session. Eg, passing SOUP_TYPE_CONTENT_SNIFFER for
feature-type will disable Content-Type sniffing on the message.
You must call this before queueing self on a session; calling it on a message that has already been queued is undefined. In particular, you cannot call this on a message that is being requeued after a redirect or authentication.
Passed: a <SoupMessage>.
Passed: a class, or a GType number.
the GType of a SessionFeature
Returns the unique idenfier for the last connection used.
This may be 0 if it was a cached resource or it has not gotten a connection yet.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: an unsigned 64-bit integer.
An id or 0 if no connection.
Gets self’s first-party <GUri>.
Passed: a <SoupMessage>.
Returned: a <GUri>.
the self’s first party <GUri>
Gets the flags on self.
Passed: a <SoupMessage>.
Returned: a <SoupMessageFlags>.
the flags
Returns whether HTTP/1 version is currently demanded for the self send.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a boolean.
#t, when HTTP/1 is demanded, #f otherwise.
Gets the HTTP version of self.
This is the minimum of the version from the request and the version from the response.
Passed: a <SoupMessage>.
Returned: a <SoupHTTPVersion>.
the HTTP version
Gets whether self is intended to be used to send OPTIONS *
to a server.
Passed: a <SoupMessage>.
Returned: a boolean.
#t if the message is options ping, or #f otherwise
Returns if this message is set as a top level navigation.
Used for same-site policy checks.
Passed: a <SoupMessage>.
Returned: a boolean.
Whether the current request is a top-level navitation
Returns the method of this message.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a string.
A method such as SOUP_METHOD_GET
Get the MessageMetrics of self.
If the flag collect-metrics is not enabled
for self this will return #f.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a <SoupMessageMetrics>, or
#f.
Retrieves the MessagePriority.
If not set this value defaults to normal.
Passed: a <SoupMessage>.
Returned: a <SoupMessagePriority>.
the priority of the message.
Returns the reason phrase for the status of this message.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a string, or #f.
the phrase
Get the remote <GSocketAddress> of the
connection associated with the message.
The returned address can be #f if the connection hasn’t been
established yet, or the resource was loaded from the disk cache. In
case of proxy connections, the remote address returned is a
<GProxyAddress>. If
Session:remote-connectable is set the returned address id for the
connection to the session’s remote connectable.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a <GSocketAddress>, or
#f.
a <GSocketAddress> or #f if the
connection hasn’t been established
Returns the headers sent with the request.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a <SoupMessageHeaders>.
The MessageHeaders
Returns the headers recieved with the response.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a <SoupMessageHeaders>.
The MessageHeaders
Gets self’s site for cookies <GUri>.
Passed: a <SoupMessage>.
Returned: a <GUri>.
the self’s site for cookies <GUri>
Returns the set status of this message.
Passed: a <SoupMessage>.
The <SoupMessage>
Returned: a <SoupStatus>.
The <SoupStatus>
Gets the name of the TLS ciphersuite negotiated for self’s connection.
Passed: a <SoupMessage>.
Returned: a string.
the name of the TLS ciphersuite, or #f if self’s connection
is not SSL.
Gets the peer’s <GTlsCertificate>
associated with self’s connection.
Note that this is not set yet during the emission of
"accept-certificate" signal.
Passed: a <SoupMessage>.
Returned: a <GTlsCertificate>, or
#f.
self’s TLS peer certificate, or #f if self’s
connection is not SSL.
Gets the errors associated with validating self’s TLS peer
certificate. Note that this is not set yet during the emission of
"accept-certificate" signal.
Passed: a <SoupMessage>.
Returned: a
<GTlsCertificateFlags>.
a <GTlsCertificateFlags> with
self’s TLS peer certificate errors.
Gets the TLS protocol version negotiated for self’s connection.
If the message connection is not SSL,
unknown is returned.
Passed: a <SoupMessage>.
Returned: a <GTlsProtocolVersion>.
Gets self’s URI.
Passed: a <SoupMessage>.
Returned: a <GUri>.
the URI self is targeted for.
Get whether SessionFeatures of the given feature-type (or a
subclass of that type) are disabled on self.
See Message.disable_feature.
Passed: a <SoupMessage>.
Passed: a class, or a GType number.
the GType of a SessionFeature
Returned: a boolean.
#t if feature is disabled, or #f otherwise.
Determines whether or not self’s connection can be kept alive for further requests after processing self.
The result is based on the HTTP version, Connection header, etc.
Passed: a <SoupMessage>.
Returned: a boolean.
#t or #f.
Creates a new empty Message, which will connect to uri.
Passed: a string.
the HTTP method for the created request
Passed: a string.
the destination endpoint (as a string)
Returned: a <SoupMessage>, or #f.
the new <SoupMessage> (or #f if uri
could not be parsed).
Creates a new Message and sets it up to send the given
encoded-form to uri via method. If method is
"GET", it will include the form data into uri’s query field, and
if method is "POST" or "PUT", it will be set as request body.
This function takes the ownership of encoded-form, that will be
released with byte-array:free when no longer in
use. See also form_encode, form_encode_hash and
form_encode_datalist.
Passed: a string.
the HTTP method for the created request (GET, POST or PUT)
Passed: a string.
the destination endpoint (as a string)
Passed: a string.
a encoded form
Returned: a <SoupMessage>, or #f.
the new <SoupMessage>, or #f if
uri-string could not be parsed or method is not "GET, "POST"
or "PUT"
Creates a new Message and sets it up to send multipart to
uri-string via POST.
Passed: a string.
the destination endpoint
Passed: a <SoupMultipart>.
Returned: a <SoupMessage>, or #f.
the new <SoupMessage>, or #f if
uri-string could not be parsed
Creates a new empty Message, which will connect to uri.
Passed: a string.
the HTTP method for the created request
Passed: a <GUri>.
the destination endpoint
Returned: a <SoupMessage>.
the new <SoupMessage>
Creates a new Message to send OPTIONS * to a server. The
path of base-uri will be ignored.
Passed: a <GUri>.
the destination endpoint
Returned: a <SoupMessage>.
the new <SoupMessage>
Queries if flags are present in the set of self’s flags.
Passed: a <SoupMessage>.
Passed: a <SoupMessageFlags>, or a list of
its symbols, or one of them.
a set of <SoupMessageFlags> values
Returned: a boolean.
#t if flags are enabled in self
Removes flags from the set of self’s flags.
Passed: a <SoupMessage>.
Passed: a <SoupMessageFlags>, or a list of
its symbols, or one of them.
a set of <SoupMessageFlags> values
Sets first-party as the main document
<GUri> for self.
For details of when and how this is used refer to the documentation for
CookieJarAcceptPolicy.
Passed: a <SoupMessage>.
Passed: a <GUri>.
the <GUri> for the self’s first party
Sets the specified flags on self.
Passed: a <SoupMessage>.
Passed: a <SoupMessageFlags>, or a list of
its symbols, or one of them.
a set of <SoupMessageFlags> values
Sets whether HTTP/1 version should be used when sending this message. Some connections can still override it, if needed.
Note the value is unset after the message send is finished.
Passed: a <SoupMessage>.
The <SoupMessage>
Passed: a boolean.
value to set
Set whether self is intended to be used to send OPTIONS *
to a server.
When set to #t, the path of Message:uri will be ignored
and Message:method set to SOUP_METHOD_OPTIONS.
Passed: a <SoupMessage>.
Passed: a boolean.
the value to set
Sets whether the current request is a top-level navitation.
See the same-site spec for more information.
Passed: a <SoupMessage>.
Passed: a boolean.
if #t indicate the current request is a top-level navigation
Set self’s HTTP method to method.
Passed: a <SoupMessage>.
Passed: a string.
the value to set
Sets the priority of a message.
Note that this won’t have any effect unless used before the message is added to the session’s message processing queue.
The message will be placed just before any other previously added message with lower priority (messages with the same priority are processed on a FIFO basis).
Setting priorities does not currently work with synchronous messages because in the synchronous/blocking case, priority ends up being determined semi-randomly by thread scheduling.
Passed: a <SoupMessage>.
Passed: a <SoupMessagePriority>, or one of
its symbols.
Set the request body of a Message.
If content-type is #f and stream is not #f the
Content-Type header will not be changed if present. The request body
needs to be set again in case self is restarted (in case of
redirection or authentication).
Passed: a <SoupMessage>.
the message
Passed: a string, or #f.
MIME Content-Type of the body, or #f if unknown
Passed: a <GInputStream>, or #f.
a <GInputStream> to read the request body
from
Passed: a 64-bit integer.
the byte length of stream or -1 if unknown
Set the request body of a Message from
<GBytes>.
If content-type is #f and bytes is not #f the
Content-Type header will not be changed if present. The request body
needs to be set again in case self is restarted (in case of
redirection or authentication).
Passed: a <SoupMessage>.
the message
Passed, or left out: a string, or #f.
MIME Content-Type of the body, or #f if unknown
Passed, or left out: a <GBytes>, or #f.
a <GBytes> with the request body data
Sets site-for-cookies as the policy URL for same-site cookies for self.
It is either the URL of the top-level document or #f depending on
whether the registrable domain of this document’s URL matches the
registrable domain of its parent’s/opener’s URL. For the top-level
document it is set to the document’s URL.
See the same-site spec for more information.
Passed: a <SoupMessage>.
Passed, or left out: a <GUri>, or #f.
the <GUri> for the self’s site for cookies
Sets the certificate to be used by self’s connection when a client certificate is requested during the TLS handshake.
You can call this as a response to "request-certificate" signal,
or before the connection is started. If certificate is #f
the handshake will continue without providing a GTlsCertificate. Note
that the <GTlsCertificate> set by this
function will be ignored if Session:tls-interaction is not
#f.
Passed: a <SoupMessage>.
Passed, or left out: a
<GTlsCertificate>, or #f.
the <GTlsCertificate> to set, or
#f
Sets self’s URI to uri.
If self has already been sent and you want to re-send it with the new URI, you need to send it again.
Passed: a <SoupMessage>.
Passed: a <GUri>.
the new <GUri>
Completes a certificate password request.
You must call this as a response to
"request-certificate-password" signal, to notify self that
the <GTlsPassword> has already been
updated.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:accept-certificate
handler). It is called as (handler self tls-peer-certificate
tls-peer-errors) ⇒ %return.
Emitted during the msg’s connection TLS handshake after an unacceptable TLS certificate has been received.
You can return #t to accept tls-certificate despite
tls-errors.
Passed: a <SoupMessage>.
Passed: a <GTlsCertificate>.
the peer’s <GTlsCertificate>
Passed: a <GTlsCertificateFlags>.
the tls errors of tls-certificate
Returned: a boolean.
#t to accept the TLS certificate and stop other handlers from
being invoked, or #f to propagate the event further.
Connect a handler with (connect object message:authenticate
handler). It is called as (handler self auth retrying) ⇒
%return.
Emitted when the message requires authentication.
If credentials are available call Auth.authenticate on
auth. If these credentials fail, the signal will be emitted
again, with retrying set to #t, which will continue until
you return without calling Auth.authenticate on auth.
Note that this may be emitted before msg’s body has been fully read.
You can authenticate auth asynchronously by calling
object:ref on auth and returning
#t. The operation will complete once either
Auth.authenticate or Auth.cancel are called.
Passed: a <SoupMessage>.
Passed: a <SoupAuth>.
the <SoupAuth> to authenticate
Passed: a boolean.
#t if this is the second (or later) attempt
Returned: a boolean.
#t to stop other handlers from being invoked or #f to
propagate the event further.
Connect a handler with (connect object message:content-sniffed
handler). It is called as (handler self type params).
This signal is emitted after "got-headers".
If content sniffing is disabled, or no content sniffing will be
performed, due to the sniffer deciding to trust the Content-Type sent by
the server, this signal is emitted immediately after
"got-headers", and type is #f.
Passed: a <SoupMessage>.
Passed: a string.
the content type that we got from sniffing
Passed: a hash table, each key a string and each value a string.
a <GHashTable> with the parameters
Connect a handler with (connect object message:finished handler).
It is called as (handler self).
Emitted when all HTTP processing is finished for a message.
(After "got_body").
Passed: a <SoupMessage>.
Connect a handler with (connect object message:got-body handler).
It is called as (handler self).
Emitted after receiving the complete message response body.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:got-body-data
handler). It is called as (handler self chunk-size).
Emitted after reading a portion of the message body from the network.
Passed: a <SoupMessage>.
Passed: an unsigned 32-bit integer.
the number of bytes read
Connect a handler with (connect object message:got-headers
handler). It is called as (handler self).
Emitted after receiving the Status-Line and response headers.
See also Message.add_header_handler and
Message.add_status_code_handler, which can be used to connect to
a subset of emissions of this signal.
If you cancel or requeue msg while processing this signal, then
the current HTTP I/O will be stopped after this signal emission
finished, and msg’s connection will be closed. (If you need to
requeue a message–eg, after handling authentication or redirection–it
is usually better to requeue it from a "got-body" handler rather
than a "got_headers" handler, so that the existing HTTP
connection can be reused.)
Passed: a <SoupMessage>.
Connect a handler with (connect object message:got-informational
handler). It is called as (handler self).
Emitted after receiving a 1xx (Informational) response for a (client-side) message.
The response_headers will be filled in with the headers associated with the informational response; however, those header values will be erased after this signal is done.
If you cancel or requeue msg while processing this signal, then the current HTTP I/O will be stopped after this signal emission finished, and msg’s connection will be closed.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:hsts-enforced
handler). It is called as (handler self).
Emitted when HSTSEnforcer has upgraded the protocol for msg
to HTTPS as a result of matching its domain with a HSTS policy.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:network-event
handler). It is called as (handler self event connection).
Emitted to indicate that some network-related event related to msg has occurred.
This essentially proxies the socket-client:event signal, but only for events that occur
while msg "owns" the connection; if msg is sent on an
existing persistent connection, then this signal will not be emitted.
(If you want to force the message to be sent on a new connection, set
the new-connection flag on it.)
See socket-client:event for
more information on what the different values of event correspond
to, and what connection will be in each case.
Passed: a <SoupMessage>.
Passed: a <GSocketClientEvent>.
the network event
Passed: a <GIOStream>.
the current state of the network connection
Connect a handler with (connect object message:request-certificate
handler). It is called as (handler self tls-connection) ⇒
%return.
Emitted during the msg’s connection TLS handshake when tls-connection requests a certificate from the client.
You can set the client certificate by calling
Message.set_tls_client_certificate and returning #t. It’s
possible to handle the request asynchornously by returning #t and
call Message.set_tls_client_certificate later once the
certificate is available. Note that this signal is not emitted if
Session:tls-interaction was set, or if
Message.set_tls_client_certificate was called before the
connection TLS handshake started.
Passed: a <SoupMessage>.
Passed: a <GTlsClientConnection>.
Returned: a boolean.
#t to handle the request, or #f to make the connection
fail with certificate-required.
Connect a handler with (connect object
message:request-certificate-password handler). It is called as
(handler self tls-password) ⇒ %return.
Emitted during the msg’s connection TLS handshake when tls-connection requests a certificate password from the client.
You can set the certificate password on password, then call
Message.tls_client_certificate_password_request_complete and
return #t to handle the signal synchronously. It’s possible to
handle the request asynchornously by calling object:ref on password, then returning #t
and call Message.tls_client_certificate_password_request_complete
later after setting the password on password. Note that this
signal is not emitted if Session:tls-interaction was set.
Passed: a <SoupMessage>.
Passed: a <GTlsPassword>.
the <GTlsPassword>
Returned: a boolean.
#t to handle the request, or #f to make the connection
fail with certificate-required.
Connect a handler with (connect object message:restarted
handler). It is called as (handler self).
Emitted when a request that was already sent once is now being sent again.
e.g. because the first attempt received a redirection response, or because we needed to use authentication.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:starting handler).
It is called as (handler self).
Emitted just before a message is sent.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:wrote-body
handler). It is called as (handler self).
Emitted immediately after writing the complete body for a message.
Passed: a <SoupMessage>.
Connect a handler with (connect object message:wrote-body-data
handler). It is called as (handler self chunk-size).
Emitted immediately after writing a portion of the message body to the network.
Passed: a <SoupMessage>.
Passed: an unsigned 32-bit integer.
the number of bytes written
Connect a handler with (connect object message:wrote-headers
handler). It is called as (handler self).
Emitted immediately after writing the request headers for a message.
Passed: a <SoupMessage>.