Interface ServerCallback
- All Superinterfaces:
FunctionPointer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ServerCallback
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
A callback used to handle requests to aServer
.default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.default void
upcall
(MemorySegment server, MemorySegment msg, MemorySegment path, MemorySegment query, MemorySegment userData) Theupcall
method is called from native code.
-
Method Details
-
run
void run(Server server, ServerMessage msg, String path, @Nullable @Nullable HashTable<String, String> query) A callback used to handle requests to aServer
.path
andquery
contain the likewise-named components of the Request-URI, subject to certain assumptions. By default,Server
decodes all percent-encoding in the URI path, such that"/foo%2Fbar"
is treated the same as"/foo/bar"
. If your server is serving resources in some non-POSIX-filesystem namespace, you may want to distinguish those as two distinct paths. In that case, you can set theServer:raw-paths
property when creating theServer
, and it will leave those characters undecoded.query
contains the query component of the Request-URI parsed according to the rules for HTML form handling. Although this is the only commonly-used query string format in HTTP, there is nothing that actually requires that HTTP URIs use that format; if your server needs to use some other format, you can just ignorequery
, and callMessage.getUri()
and parse the URI's query field yourself.See
Server.addHandler(java.lang.String, org.gnome.soup.ServerCallback)
andServer.addEarlyHandler(java.lang.String, org.gnome.soup.ServerCallback)
for details of what handlers can/should do. -
upcall
default void upcall(MemorySegment server, MemorySegment msg, MemorySegment path, MemorySegment query, MemorySegment userData) Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.soup.Server, org.gnome.soup.ServerMessage, java.lang.String, org.gnome.glib.HashTable<java.lang.String, java.lang.String>)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-