1.22 <SoupServerMessage>

Class: <SoupServerMessage>

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.

Properties

Property: server-message:tls-peer-certificate self

The peer’s <GTlsCertificate> associated with the message

Its value is a <GTlsCertificate>, or #f.

It is read only.

Property: server-message:tls-peer-certificate-errors self

The verification errors on ServerMessage:tls-peer-certificate

Its value is a <GTlsCertificateFlags>.

It is read only.

Procedures

Method: server-message:get-http-version self ⇒ %return
Method: get-http-version self ⇒ %return

Get the HTTP version of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <SoupHTTPVersion>.

a <SoupHTTPVersion>.

Method: server-message:get-local-address self ⇒ %return
Method: get-local-address self ⇒ %return

Retrieves the <GSocketAddress> associated with the local end of a connection.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

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.

Method: server-message:get-method self ⇒ %return
Method: get-method self ⇒ %return

Get the HTTP method of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a string.

the HTTP method.

Method: server-message:get-reason-phrase self ⇒ %return
Method: get-reason-phrase self ⇒ %return

Get the HTTP reason phrase of self.

self

Passed: a <SoupServerMessage>.

a #SoupServerMessage:

%return

Returned: a string, or #f.

the reason phrase.

Method: server-message:get-remote-address self ⇒ %return
Method: get-remote-address self ⇒ %return

Retrieves the <GSocketAddress> associated with the remote end of a connection.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

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.

Method: server-message:get-remote-host self ⇒ %return
Method: get-remote-host self ⇒ %return

Retrieves the IP address associated with the remote end of a connection.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

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.

Method: server-message:get-request-body self ⇒ %return
Method: get-request-body self ⇒ %return

Get the request body of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <SoupMessageBody>.

a <SoupMessageBody>.

Method: server-message:get-request-headers self ⇒ %return
Method: get-request-headers self ⇒ %return

Get the request headers of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <SoupMessageHeaders>.

a <SoupMessageHeaders> with the request headers.

Method: server-message:get-response-body self ⇒ %return
Method: get-response-body self ⇒ %return

Get the response body of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <SoupMessageBody>.

a <SoupMessageBody>.

Method: server-message:get-response-headers self ⇒ %return
Method: get-response-headers self ⇒ %return

Get the response headers of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <SoupMessageHeaders>.

a <SoupMessageHeaders> with the response headers.

Method: server-message:get-socket self ⇒ %return
Method: get-socket self ⇒ %return

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.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <GSocket>, or #f.

the <GSocket> that self is associated with, #f if you used Server.accept_iostream.

Method: server-message:get-status self ⇒ %return
Method: get-status self ⇒ %return

Get the HTTP status code of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: an unsigned 32-bit integer.

the HTTP status code.

Method: server-message:get-tls-peer-certificate self ⇒ %return
Method: get-tls-peer-certificate self ⇒ %return

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.

self

Passed: a <SoupServerMessage>.

a <SoupMessage>

%return

Returned: a <GTlsCertificate>, or #f.

self’s TLS peer certificate, or #f if self’s connection is not SSL.

Method: server-message:get-tls-peer-certificate-errors self ⇒ %return
Method: get-tls-peer-certificate-errors self ⇒ %return

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.

self

Passed: a <SoupServerMessage>.

a <SoupMessage>

%return

Returned: a <GTlsCertificateFlags>.

a <GTlsCertificateFlags> with self’s TLS peer certificate errors.

Method: server-message:get-uri self ⇒ %return
Method: get-uri self ⇒ %return

Get self’s URI.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a <GUri>.

a <GUri>

Method: server-message:is-options-ping? self ⇒ %return
Method: is-options-ping? self ⇒ %return

Gets if self represents an OPTIONS message with the path *.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

Returned: a boolean.

#t if is an OPTIONS ping

Method: server-message:pause self
Method: pause self

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.

self

Passed: a <SoupServerMessage>.

a SoupServerMessage

Method: server-message:set-http-version self version
Method: set-http-version self version

Set the HTTP version of self.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

version

Passed: a <SoupHTTPVersion>, or one of its symbols.

a <SoupHTTPVersion>

Method: server-message:set-redirect self status-code redirect-uri
Method: set-redirect self status-code redirect-uri

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.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

status-code

Passed: an unsigned 32-bit integer.

a 3xx status code

redirect-uri

Passed: a string.

the URI to redirect self to

Method: server-message:set-response self content-type resp-use resp-body
Method: set-response self content-type resp-use resp-body

Convenience function to set the response body of a ServerMessage. If content-type is #f, the response body must be empty as well.

self

Passed: a <SoupServerMessage>.

the message

content-type

Passed: a string, or #f.

MIME Content-Type of the body

resp-use

Passed: a <SoupMemoryUse>, or one of its symbols.

a <SoupMemoryUse> describing how to handle resp-body

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.

resp-length

Not passed: guile-gi gives the length of resp-body.

the byte length of resp-body.

Method: server-message:set-status self status-code [reason-phrase]
Method: set-status self status-code [reason-phrase]

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.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

status-code

Passed: an unsigned 32-bit integer.

an HTTP status code

reason-phrase

Passed, or left out: a string, or #f.

a reason phrase

Method: server-message:steal-connection self ⇒ %return
Method: steal-connection self ⇒ %return

"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.

self

Passed: a <SoupServerMessage>.

a <SoupServerMessage>

%return

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.

Method: server-message:unpause self
Method: unpause self

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.

self

Passed: a <SoupServerMessage>.

a SoupServerMessage

Signals

Signal: server-message:accept-certificate

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.

self

Passed: a <SoupServerMessage>.

tls-peer-certificate

Passed: a <GTlsCertificate>.

the peer’s <GTlsCertificate>

tls-peer-errors

Passed: a <GTlsCertificateFlags>.

the tls errors of tls-certificate

%return

Returned: a boolean.

#t to accept the TLS certificate and stop other handlers from being invoked, or #f to propagate the event further.

Signal: server-message:connected

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.

self

Passed: a <SoupServerMessage>.

Signal: server-message:disconnected

Connect a handler with (connect object server-message:disconnected handler). It is called as (handler self).

Emitted when the msg’s socket is disconnected.

self

Passed: a <SoupServerMessage>.

Signal: server-message:finished

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").

self

Passed: a <SoupServerMessage>.

Signal: server-message:got-body

Connect a handler with (connect object server-message:got-body handler). It is called as (handler self).

Emitted after receiving the complete request body.

self

Passed: a <SoupServerMessage>.

Signal: server-message:got-chunk

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.

self

Passed: a <SoupServerMessage>.

chunk

Passed: a <GBytes>.

the just-read chunk

Signal: server-message:got-headers

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.

self

Passed: a <SoupServerMessage>.

Signal: server-message:wrote-body

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.

self

Passed: a <SoupServerMessage>.

Signal: server-message:wrote-body-data

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.

self

Passed: a <SoupServerMessage>.

chunk-size

Passed: an unsigned 32-bit integer.

the number of bytes written

Signal: server-message:wrote-chunk

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".

self

Passed: a <SoupServerMessage>.

Signal: server-message:wrote-headers

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.

self

Passed: a <SoupServerMessage>.

Signal: server-message:wrote-informational

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.

self

Passed: a <SoupServerMessage>.