Class Server
- All Implemented Interfaces:
Proxy
SoupServer
implements a simple HTTP server.
To begin, create a server using Server(java.lang.String, java.lang.Object...)
. Add at least one
handler by calling addHandler(java.lang.String, org.gnome.soup.ServerCallback)
or
addEarlyHandler(java.lang.String, org.gnome.soup.ServerCallback)
; the handler will be called to
process any requests underneath the path you pass. (If you want all
requests to go to the same handler, just pass "/" (or null
) for
the path.)
When a new connection is accepted (or a new request is started on
an existing persistent connection), the SoupServer
will emit
Server::request-started
and then begin processing the request
as described below, but note that once the message is assigned a
status-code, then callbacks after that point will be
skipped. Note also that it is not defined when the callbacks happen
relative to various ServerMessage
signals.
Once the headers have been read, SoupServer
will check if there is
a AuthDomain
(qv)
covering the Request-URI; if so, and if the
message does not contain suitable authorization, then the
AuthDomain
will set a status of Status.UNAUTHORIZED
on
the message.
After checking for authorization, SoupServer
will look for "early"
handlers (added with addEarlyHandler(java.lang.String, org.gnome.soup.ServerCallback)
) matching the
Request-URI. If one is found, it will be run; in particular, this
can be used to connect to signals to do a streaming read of the
request body.
(At this point, if the request headers contain Expect:
100-continue
, and a status code has been set, then
SoupServer
will skip the remaining steps and return the response.
If the request headers contain Expect:
100-continue
and no status code has been set,
SoupServer
will return a Status.CONTINUE
status before
continuing.)
The server will then read in the response body (if present). At
this point, if there are no handlers at all defined for the
Request-URI, then the server will return Status.NOT_FOUND
to
the client.
Otherwise (assuming no previous step assigned a status to the
message) any "normal" handlers (added with
addHandler(java.lang.String, org.gnome.soup.ServerCallback)
) for the message's Request-URI will be
run.
Then, if the path has a WebSocket handler registered (and has
not yet been assigned a status), SoupServer
will attempt to
validate the WebSocket handshake, filling in the response and
setting a status of Status.SWITCHING_PROTOCOLS
or
Status.BAD_REQUEST
accordingly.
If the message still has no status code at this point (and has not
been paused with ServerMessage.pause()
), then it will be
given a status of Status.INTERNAL_SERVER_ERROR
(because at
least one handler ran, but returned without assigning a status).
Finally, the server will emit Server::request-finished
(or
Server::request-aborted
if an I/O error occurred before
handling was completed).
If you want to handle the special "*" URI (eg, "OPTIONS *"), you must explicitly register a handler for "*"; the default handler will not be used for that case.
If you want to process https connections in addition to (or instead
of) http connections, you can set the Server:tls-certificate
property.
Once the server is set up, make one or more calls to
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
, listenLocal(int, java.util.Set<org.gnome.soup.ServerListenOptions>)
, or
listenAll(int, java.util.Set<org.gnome.soup.ServerListenOptions>)
to tell it where to listen for
connections. (All ports on a SoupServer
use the same handlers; if
you need to handle some ports differently, such as returning
different data for http and https, you'll need to create multiple
SoupServer
s, or else check the passed-in URI in the handler
function.).
SoupServer
will begin processing connections as soon as you return
to (or start) the main loop for the current thread-default
GLib.MainContext
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Server.Builder<B extends Server.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theRequestAbortedCallback
callback.static interface
Functional interface declaration of theRequestFinishedCallback
callback.static interface
Functional interface declaration of theRequestReadCallback
callback.static interface
Functional interface declaration of theRequestStartedCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionServer
(MemorySegment address) Create a Server proxy instance for the provided memory address.Creates a newSoupServer
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptIostream
(IOStream stream, @Nullable SocketAddress localAddr, @Nullable SocketAddress remoteAddr) Adds a new client stream to the this Server.void
addAuthDomain
(AuthDomain authDomain) Adds an authentication domain to this Server.void
addEarlyHandler
(@Nullable String path, ServerCallback callback) Adds an "early" handler to this Server for requests prefixed bypath
.void
addHandler
(@Nullable String path, ServerCallback callback) Adds a handler to this Server for requests prefixed bypath
.void
addWebsocketExtension
(Type extensionType) Add support for a WebSocket extension of the givenextensionType
.void
addWebsocketHandler
(@Nullable String path, @Nullable String origin, @Nullable String[] protocols, ServerWebsocketCallback callback) Adds a WebSocket handler to this Server for requests prefixed bypath
.protected Server
asParent()
Returns this instance as if it were its parent type.static Server.Builder
<? extends Server.Builder> builder()
AServer.Builder
object constructs aServer
with the specified properties.void
Closes and frees this Server's listening sockets.void
emitRequestAborted
(ServerMessage message) Emits the "request-aborted" signal.void
emitRequestFinished
(ServerMessage message) Emits the "request-finished" signal.void
emitRequestRead
(ServerMessage message) Emits the "request-read" signal.void
emitRequestStarted
(ServerMessage message) Emits the "request-started" signal.Gets this Server's list of listening sockets.static MemoryLayout
The memory layout of the native struct.Gets the this Server SSL/TLS client authentication mode.Gets the this Server SSL/TLS certificate.Gets the this Server SSL/TLS database.static Type
getType()
Get the GType of the Server classgetUris()
Gets a list of URIs corresponding to the interfaces this Server is listening on.boolean
isHttps()
Checks whether this Server is capable of https.boolean
listen
(SocketAddress address, Set<ServerListenOptions> options) Attempts to set up this Server to listen for connections onaddress
.boolean
listen
(SocketAddress address, ServerListenOptions... options) Attempts to set up this Server to listen for connections onaddress
.boolean
listenAll
(int port, Set<ServerListenOptions> options) Attempts to set up this Server to listen for connections on all interfaces on the system.boolean
listenAll
(int port, ServerListenOptions... options) Attempts to set up this Server to listen for connections on all interfaces on the system.boolean
listenLocal
(int port, Set<ServerListenOptions> options) Attempts to set up this Server to listen for connections on "localhost".boolean
listenLocal
(int port, ServerListenOptions... options) Attempts to set up this Server to listen for connections on "localhost".boolean
listenSocket
(Socket socket, Set<ServerListenOptions> options) Attempts to set up this Server to listen for connections onsocket
.boolean
listenSocket
(Socket socket, ServerListenOptions... options) Attempts to set up this Server to listen for connections onsocket
.Emitted when processing has failed for a message.Emitted when the server has finished writing a response to a request.onRequestRead
(Server.RequestReadCallback handler) Emitted when the server has successfully read a request.Emitted when the server has started reading a new request.void
Deprecated.Use soup_server_message_pause() instead.void
removeAuthDomain
(AuthDomain authDomain) RemovesauthDomain
from this Server.void
removeHandler
(String path) Removes all handlers (early and normal) registered atpath
.void
removeWebsocketExtension
(Type extensionType) Removes support for WebSocket extension of typeextensionType
(or any subclass ofextensionType
) from this Server.protected void
protected void
protected void
requestRead
(ServerMessage msg) protected void
void
Sets this Server'sGTlsAuthenticationMode
to use for SSL/TLS client authentication.void
setTlsCertificate
(TlsCertificate certificate) Sets this Server up to do https, using the given SSL/TLScertificate
.void
setTlsDatabase
(TlsDatabase tlsDatabase) Sets this Server'sGTlsDatabase
to use for validating SSL/TLS client certificates.void
Deprecated.Use soup_server_message_unpause() instead.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Server
Create a Server proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Server
Creates a newSoupServer
.This is exactly equivalent to calling
GObject(org.gnome.glib.Type, java.lang.String, java.lang.Object...)
and specifyingSOUP_TYPE_SERVER
as the type.- Parameters:
optname1
- name of first property to setvarargs
- value ofoptname1
, followed by additional property/value pairs- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
acceptIostream
public boolean acceptIostream(IOStream stream, @Nullable @Nullable SocketAddress localAddr, @Nullable @Nullable SocketAddress remoteAddr) throws GErrorException Adds a new client stream to the this Server.- Parameters:
stream
- aGIOStream
localAddr
- the localGSocketAddress
associated with thestream
remoteAddr
- the remoteGSocketAddress
associated with thestream
- Returns:
true
on success,false
if the stream could not be accepted or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
addAuthDomain
Adds an authentication domain to this Server.Each auth domain will have the chance to require authentication for each request that comes in; normally auth domains will require authentication for requests on certain paths that they have been set up to watch, or that meet other criteria set by the caller. If an auth domain determines that a request requires authentication (and the request doesn't contain authentication), this Server will automatically reject the request with an appropriate status (401 Unauthorized or 407 Proxy Authentication Required). If the request used the SoupServer:100-continue Expectation, this Server will reject it before the request body is sent.
- Parameters:
authDomain
- aSoupAuthDomain
-
addEarlyHandler
Adds an "early" handler to this Server for requests prefixed bypath
.Note that "normal" and "early" handlers are matched up together, so if you add a normal handler for "/foo" and an early handler for "/foo/bar", then a request to "/foo/bar" (or any path below it) will run only the early handler. (But if you add both handlers at the same path, then both will get run.)
For requests under
path
(that have not already been assigned a status code by aAuthDomain
or a signal handler),callback
will be invoked after receiving the request headers, but before receiving the request body; the message's method and request-headers properties will be set.Early handlers are generally used for processing requests with request bodies in a streaming fashion. If you determine that the request will contain a message body, normally you would call
MessageBody.setAccumulate(boolean)
on the message's request-body to turn off request-body accumulation, and connect to the message'sServerMessage::got-chunk
signal to process each chunk as it comes in.To complete the message processing after the full message body has been read, you can either also connect to
ServerMessage::got-body
, or else you can register a non-early handler forpath
as well. As long as you have not set the status-code by the timeServerMessage::got-body
is emitted, the non-early handler will be run as well.- Parameters:
path
- the toplevel path for the handlercallback
- callback to invoke for requests underpath
-
addHandler
Adds a handler to this Server for requests prefixed bypath
.If
path
isnull
or "/", then this will be the default handler for all requests that don't have a more specific handler. (Note though that if you want to handle requests to the special "*" URI, you must explicitly register a handler for "*"; the default handler will not be used for that case.)For requests under
path
(that have not already been assigned a status code by aAuthDomain
, an early server handler, or a signal handler),callback
will be invoked after receiving the request body; theServerMessage
's method, request-headers, and request-body properties will be set.After determining what to do with the request, the callback must at a minimum call
ServerMessage.setStatus(int, java.lang.String)
on the message to set the response status code. Additionally, it may set response headers and/or fill in the response body.If the callback cannot fully fill in the response before returning (eg, if it needs to wait for information from a database, or another network server), it should call
ServerMessage.pause()
to tell this Server to not send the response right away. When the response is ready, callServerMessage.unpause()
to cause it to be sent.To send the response body a bit at a time using "chunked" encoding, first call
MessageHeaders.setEncoding(org.gnome.soup.Encoding)
to setEncoding.CHUNKED
on the response-headers. Then callMessageBody.append(byte[])
(orMessageBody.appendBytes(org.gnome.glib.Bytes)
)) to append each chunk as it becomes ready, andServerMessage.unpause()
to make sure it's running. (The server will automatically pause the message if it is using chunked encoding but no more chunks are available.) When you are done, callMessageBody.complete()
to indicate that no more chunks are coming.- Parameters:
path
- the toplevel path for the handlercallback
- callback to invoke for requests underpath
-
addWebsocketExtension
Add support for a WebSocket extension of the givenextensionType
.When a WebSocket client requests an extension of
extensionType
, a newWebsocketExtension
of typeextensionType
will be created to handle the request.Note that
WebsocketExtensionDeflate
is supported by default, useremoveWebsocketExtension(org.gnome.glib.Type)
if you want to disable it.- Parameters:
extensionType
- aGType
-
addWebsocketHandler
public void addWebsocketHandler(@Nullable @Nullable String path, @Nullable @Nullable String origin, @Nullable @Nullable String[] protocols, ServerWebsocketCallback callback) Adds a WebSocket handler to this Server for requests prefixed bypath
.If
path
isnull
or "/", then this will be the default handler for all requests that don't have a more specific handler.When a path has a WebSocket handler registered, this Server will check incoming requests for WebSocket handshakes after all other handlers have run (unless some earlier handler has already set a status code on the message), and update the request's status, response headers, and response body accordingly.
If
origin
is non-null
, then only requests containing a matching "Origin" header will be accepted. Ifprotocols
is non-null
, then only requests containing a compatible "Sec-WebSocket-Protocols" header will be accepted. More complicated requirements can be handled by adding a normal handler topath
, and having it perform whatever checks are needed and setting a failure status code if the handshake should be rejected.- Parameters:
path
- the toplevel path for the handlerorigin
- the origin of the connectionprotocols
- the protocols supported by this handlercallback
- callback to invoke for successful WebSocket requests underpath
-
disconnect
public void disconnect()Closes and frees this Server's listening sockets.Note that if there are currently requests in progress on this Server, that they will continue to be processed if this Server's
GLib.MainContext
is still running.You can call
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
, etc, after calling this function if you want to start listening again. -
getListeners
-
getTlsAuthMode
Gets the this Server SSL/TLS client authentication mode.- Returns:
- a
GTlsAuthenticationMode
-
getTlsCertificate
Gets the this Server SSL/TLS certificate.- Returns:
- a
GTlsCertificate
ornull
-
getTlsDatabase
-
getUris
Gets a list of URIs corresponding to the interfaces this Server is listening on.These will contain IP addresses, not hostnames, and will also indicate whether the given listener is http or https.
Note that if you used
listenAll(int, java.util.Set<org.gnome.soup.ServerListenOptions>)
the returned URIs will use the addresses0.0.0.0
and::
, rather than actually returning separate URIs for each interface on the system.- Returns:
- a list of
GUris
, which you must free when you are done with it.
-
isHttps
public boolean isHttps()Checks whether this Server is capable of https.In order for a server to run https, you must call
setTlsCertificate(org.gnome.gio.TlsCertificate)
, or set theServer:tls-certificate
property, to provide it with a certificate to use.If you are using the deprecated single-listener APIs, then a return value of
true
indicates that theSoupServer
serves https exclusively. If you are usinglisten(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
, etc, then atrue
return value merely indicates that the server is able to do https, regardless of whether it actually currently is or not. UsegetUris()
to see if it currently has any https listeners.- Returns:
true
if this Server is configured to serve https.
-
listen
public boolean listen(SocketAddress address, Set<ServerListenOptions> options) throws GErrorException Attempts to set up this Server to listen for connections onaddress
.If
options
includesServerListenOptions.HTTPS
, and this Server has been configured for TLS, then this Server will listen for https connections on this port. Otherwise it will listen for plain http.You may call this method (along with the other "listen" methods) any number of times on a server, if you want to listen on multiple ports, or set up both http and https service.
After calling this method, this Server will begin accepting and processing connections as soon as the appropriate
GLib.MainContext
is run.Note that this API does not make use of dual IPv4/IPv6 sockets; if
address
is an IPv6 address, it will only accept IPv6 connections. You must configure IPv4 listening separately.- Parameters:
address
- the address of the interface to listen onoptions
- listening options for this server- Returns:
true
on success,false
ifaddress
could not be bound or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listen
Attempts to set up this Server to listen for connections onaddress
.If
options
includesServerListenOptions.HTTPS
, and this Server has been configured for TLS, then this Server will listen for https connections on this port. Otherwise it will listen for plain http.You may call this method (along with the other "listen" methods) any number of times on a server, if you want to listen on multiple ports, or set up both http and https service.
After calling this method, this Server will begin accepting and processing connections as soon as the appropriate
GLib.MainContext
is run.Note that this API does not make use of dual IPv4/IPv6 sockets; if
address
is an IPv6 address, it will only accept IPv6 connections. You must configure IPv4 listening separately.- Parameters:
address
- the address of the interface to listen onoptions
- listening options for this server- Returns:
true
on success,false
ifaddress
could not be bound or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listenAll
Attempts to set up this Server to listen for connections on all interfaces on the system.That is, it listens on the addresses
0.0.0.0
and/or::
, depending on whetheroptions
includesServerListenOptions.IPV4_ONLY
,ServerListenOptions.IPV6_ONLY
, or neither.) Ifport
is specified, this Server will listen on that port. If it is 0, this Server will find an unused port to listen on. (In that case, you can usegetUris()
to find out what port it ended up choosing.See
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
for more details.- Parameters:
port
- the port to listen on, or 0options
- listening options for this server- Returns:
true
on success,false
ifport
could not be bound or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listenAll
Attempts to set up this Server to listen for connections on all interfaces on the system.That is, it listens on the addresses
0.0.0.0
and/or::
, depending on whetheroptions
includesServerListenOptions.IPV4_ONLY
,ServerListenOptions.IPV6_ONLY
, or neither.) Ifport
is specified, this Server will listen on that port. If it is 0, this Server will find an unused port to listen on. (In that case, you can usegetUris()
to find out what port it ended up choosing.See
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
for more details.- Parameters:
port
- the port to listen on, or 0options
- listening options for this server- Returns:
true
on success,false
ifport
could not be bound or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listenLocal
Attempts to set up this Server to listen for connections on "localhost".That is,
127.0.0.1
and/or::1
, depending on whetheroptions
includesServerListenOptions.IPV4_ONLY
,ServerListenOptions.IPV6_ONLY
, or neither). Ifport
is specified, this Server will listen on that port. If it is 0, this Server will find an unused port to listen on. (In that case, you can usegetUris()
to find out what port it ended up choosing.See
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
for more details.- Parameters:
port
- the port to listen on, or 0options
- listening options for this server- Returns:
true
on success,false
ifport
could not be bound or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listenLocal
Attempts to set up this Server to listen for connections on "localhost".That is,
127.0.0.1
and/or::1
, depending on whetheroptions
includesServerListenOptions.IPV4_ONLY
,ServerListenOptions.IPV6_ONLY
, or neither). Ifport
is specified, this Server will listen on that port. If it is 0, this Server will find an unused port to listen on. (In that case, you can usegetUris()
to find out what port it ended up choosing.See
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
for more details.- Parameters:
port
- the port to listen on, or 0options
- listening options for this server- Returns:
true
on success,false
ifport
could not be bound or any other error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listenSocket
Attempts to set up this Server to listen for connections onsocket
.See
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
for more details.- Parameters:
socket
- a listeningGSocket
options
- listening options for this server- Returns:
true
on success,false
if an error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
listenSocket
Attempts to set up this Server to listen for connections onsocket
.See
listen(org.gnome.gio.SocketAddress, java.util.Set<org.gnome.soup.ServerListenOptions>)
for more details.- Parameters:
socket
- a listeningGSocket
options
- listening options for this server- Returns:
true
on success,false
if an error occurred (in which caseerror
will be set).- Throws:
GErrorException
- seeGError
-
pauseMessage
Deprecated.Use soup_server_message_pause() instead.Pauses I/O onmsg
.This can be used when you need to return from the server handler without having the full response ready yet. Use
unpauseMessage(org.gnome.soup.ServerMessage)
to resume I/O.This must only be called on a
ServerMessage
which was created by theSoupServer
and are currently doing I/O, such as those passed into aServerCallback
or emitted in aServer::request-read
signal.- Parameters:
msg
- aSoupServerMessage
associated with this Server.
-
removeAuthDomain
RemovesauthDomain
from this Server.- Parameters:
authDomain
- aSoupAuthDomain
-
removeHandler
Removes all handlers (early and normal) registered atpath
.- Parameters:
path
- the toplevel path for the handler
-
removeWebsocketExtension
Removes support for WebSocket extension of typeextensionType
(or any subclass ofextensionType
) from this Server.- Parameters:
extensionType
- aGType
-
setTlsAuthMode
Sets this Server'sGTlsAuthenticationMode
to use for SSL/TLS client authentication.- Parameters:
mode
- aGTlsAuthenticationMode
-
setTlsCertificate
Sets this Server up to do https, using the given SSL/TLScertificate
.- Parameters:
certificate
- aGTlsCertificate
-
setTlsDatabase
Sets this Server'sGTlsDatabase
to use for validating SSL/TLS client certificates.- Parameters:
tlsDatabase
- aGTlsDatabase
-
unpauseMessage
Deprecated.Use soup_server_message_unpause() instead.Resumes I/O onmsg
.Use this to resume after calling
pauseMessage(org.gnome.soup.ServerMessage)
, or after adding a new chunk to a chunked response.I/O won't actually resume until you return to the main loop.
This must only be called on a
ServerMessage
which was created by theSoupServer
and are currently doing I/O, such as those passed into aServerCallback
or emitted in aServer::request-read
signal.- Parameters:
msg
- aSoupServerMessage
associated with this Server.
-
requestAborted
-
requestFinished
-
requestRead
-
requestStarted
-
onRequestAborted
public SignalConnection<Server.RequestAbortedCallback> onRequestAborted(Server.RequestAbortedCallback handler) Emitted when processing has failed for a message.This could mean either that it could not be read (if
Server::request-read
has not been emitted for it yet), or that the response could not be written back (ifServer::request-read
has been emitted butServer::request-finished
has not been).message
is in an undefined state when this signal is emitted; the signal exists primarily to allow the server to free any state that it may have allocated inServer::request-started
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRequestAborted
Emits the "request-aborted" signal. SeeonRequestAborted(org.gnome.soup.Server.RequestAbortedCallback)
. -
onRequestFinished
public SignalConnection<Server.RequestFinishedCallback> onRequestFinished(Server.RequestFinishedCallback handler) Emitted when the server has finished writing a response to a request.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRequestFinished
Emits the "request-finished" signal. SeeonRequestFinished(org.gnome.soup.Server.RequestFinishedCallback)
. -
onRequestRead
public SignalConnection<Server.RequestReadCallback> onRequestRead(Server.RequestReadCallback handler) Emitted when the server has successfully read a request.message
will have all of its request-side information filled in, and if the message was authenticated,client
will have information about that. This signal is emitted before any (non-early) handlers are called for the message, and if it sets the message'sstatus_code
, then normal handler processing will be skipped.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRequestRead
Emits the "request-read" signal. SeeonRequestRead(org.gnome.soup.Server.RequestReadCallback)
. -
onRequestStarted
public SignalConnection<Server.RequestStartedCallback> onRequestStarted(Server.RequestStartedCallback handler) Emitted when the server has started reading a new request.message
will be completely blank; not even the Request-Line will have been read yet. About the only thing you can usefully do with it is connect to its signals.If the request is read successfully, this will eventually be followed by a
Server::request_read signal
. If a response is then sent, the request processing will end with aServer::request-finished
signal. If a network error occurs, the processing will instead end withServer::request-aborted
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRequestStarted
Emits the "request-started" signal. SeeonRequestStarted(org.gnome.soup.Server.RequestStartedCallback)
. -
builder
AServer.Builder
object constructs aServer
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withServer.Builder.build()
.
-