It derives from <GObject>.
An HTTP server request and response pair.
A ServerMessage represents an HTTP message that is being sent or
received on a Server.
Server will create ServerMessages 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 ServerMessage
combines both the request and the response.
The peer’s <GTlsCertificate> associated
with the message
Its value is a <GTlsCertificate>, or
#f.
It is read only.
The verification errors on ServerMessage:tls-peer-certificate
Its value is a
<GTlsCertificateFlags>.
It is read only.
Get the HTTP version of self.
Passed: a <SoupServerMessage>.
Returned: a <SoupHTTPVersion>.
Retrieves the <GSocketAddress>
associated with the local end of a connection.
Passed: a <SoupServerMessage>.
Returned: a <GSocketAddress>, or
#f.
the <GSocketAddress> associated with the
local end of a connection, it may be #f if you used
Server.accept_iostream.
Get the HTTP method of self.
Passed: a <SoupServerMessage>.
Returned: a string.
the HTTP method.
Get the HTTP reason phrase of self.
Passed: a <SoupServerMessage>.
a #SoupServerMessage:
Returned: a string, or #f.
the reason phrase.
Retrieves the <GSocketAddress>
associated with the remote end of a connection.
Passed: a <SoupServerMessage>.
Returned: a <GSocketAddress>, or
#f.
the <GSocketAddress> associated with the
remote end of a connection, it may be #f if you used
Server.accept_iostream.
Retrieves the IP address associated with the remote end of a connection.
Passed: a <SoupServerMessage>.
Returned: a string, or #f.
the IP address associated with the remote end of a connection, it may be
#f if you used Server.accept_iostream.
Get the request body of self.
Passed: a <SoupServerMessage>.
Returned: a <SoupMessageBody>.
Get the request headers of self.
Passed: a <SoupServerMessage>.
Returned: a <SoupMessageHeaders>.
a <SoupMessageHeaders> with the request
headers.
Get the response body of self.
Passed: a <SoupServerMessage>.
Returned: a <SoupMessageBody>.
Get the response headers of self.
Passed: a <SoupServerMessage>.
Returned: a <SoupMessageHeaders>.
a <SoupMessageHeaders> with the response
headers.
Retrieves the <GSocket> 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.
Passed: a <SoupServerMessage>.
Returned: a <GSocket>, or #f.
the <GSocket> that self is associated
with, #f if you used Server.accept_iostream.
Get the HTTP status code of self.
Passed: a <SoupServerMessage>.
Returned: an unsigned 32-bit integer.
the HTTP status code.
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.
Passed: a <SoupServerMessage>.
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 SoupServerMessage::accept-certificate signal.
Passed: a <SoupServerMessage>.
Returned: a
<GTlsCertificateFlags>.
a <GTlsCertificateFlags> with
self’s TLS peer certificate errors.
Get self’s URI.
Passed: a <SoupServerMessage>.
Returned: a <GUri>.
a <GUri>
Gets if self represents an OPTIONS message with the path *.
Passed: a <SoupServerMessage>.
Returned: a boolean.
#t if is an OPTIONS ping
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 ServerMessage.unpause to
resume I/O.
Passed: a <SoupServerMessage>.
a SoupServerMessage
Set the HTTP version of self.
Passed: a <SoupServerMessage>.
Passed: a <SoupHTTPVersion>, or one of its
symbols.
Sets self’s status_code to status-code and adds a Location
header pointing to redirect-uri. Use this from a 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.
Passed: a <SoupServerMessage>.
Passed: an unsigned 32-bit integer.
a 3xx status code
Passed: a string.
the URI to redirect self to
Convenience function to set the response body of a ServerMessage.
If content-type is #f, the response body must be empty as
well.
Passed: a <SoupServerMessage>.
the message
Passed: a string, or #f.
MIME Content-Type of the body
Passed: a <SoupMemoryUse>, or one of its
symbols.
a <SoupMemoryUse> describing how to handle
resp-body
Passed: a bytevector, or a list or vector, each an unsigned 8-bit
integer, or #f.
a data buffer containing the body of the message response.
Not passed: guile-gi gives the length of resp-body.
the byte length of resp-body.
Sets self’s status code to status-code.
If status-code is a known value and reason-phrase is
#f, the reason_phrase will be set automatically.
Passed: a <SoupServerMessage>.
Passed: an unsigned 32-bit integer.
an HTTP status code
Passed, or left out: a string, or #f.
a reason phrase
"Steals" the HTTP connection associated with self from its
Server. 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" or "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.
Passed: a <SoupServerMessage>.
Returned: a <GIOStream>.
the <GIOStream> formerly associated with
self (or #f if self was no longer associated with a
connection). No guarantees are made about what kind of
<GIOStream> is returned.
Resumes I/O on self.
Use this to resume after calling 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.
Passed: a <SoupServerMessage>.
a SoupServerMessage
Connect a handler with (connect object
server-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 client TLS
certificate has been received. You can return #t to accept
tls-certificate despite tls-errors.
Passed: a <SoupServerMessage>.
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 server-message:connected
handler). It is called as (handler self).
Emitted when the msg’s socket is connected and the TLS handshake completed.
Passed: a <SoupServerMessage>.
Connect a handler with (connect object server-message:disconnected
handler). It is called as (handler self).
Emitted when the msg’s socket is disconnected.
Passed: a <SoupServerMessage>.
Connect a handler with (connect object server-message:finished
handler). It is called as (handler self).
Emitted when all HTTP processing is finished for a message. (After
"wrote-body").
Passed: a <SoupServerMessage>.
Connect a handler with (connect object server-message:got-body
handler). It is called as (handler self).
Emitted after receiving the complete request body.
Passed: a <SoupServerMessage>.
Connect a handler with (connect object server-message:got-chunk
handler). It is called as (handler self 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.
Passed: a <SoupServerMessage>.
Passed: a <GBytes>.
the just-read chunk
Connect a handler with (connect object server-message:got-headers
handler). It is called as (handler self).
Emitted after receiving the Request-Line and request headers.
Passed: a <SoupServerMessage>.
Connect a handler with (connect object server-message:wrote-body
handler). It is called as (handler self).
Emitted immediately after writing the complete response body for a message.
Passed: a <SoupServerMessage>.
Connect a handler with (connect object
server-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 <SoupServerMessage>.
Passed: an unsigned 32-bit integer.
the number of bytes written
Connect a handler with (connect object server-message:wrote-chunk
handler). It is called as (handler self).
Emitted immediately after writing a body chunk for a message.
Note that this signal is not parallel to "got-chunk"; it is
emitted only when a complete chunk (added with MessageBody.append
or MessageBody.append_bytes has been written. To get more useful
continuous progress information, use "wrote-body-data".
Passed: a <SoupServerMessage>.
Connect a handler with (connect object
server-message:wrote-headers handler). It is called as (handler
self).
Emitted immediately after writing the response headers for a message.
Passed: a <SoupServerMessage>.
Connect a handler with (connect object
server-message:wrote-informational handler). It is called as
(handler self).
Emitted immediately after writing a 1xx (Informational) response.
Passed: a <SoupServerMessage>.