[libsoup] soup-server: add soup_server_accept_iostream()
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup-server: add soup_server_accept_iostream()
- Date: Fri, 20 Feb 2015 23:18:20 +0000 (UTC)
commit 50bdc5c2c710592f2876a2b84561f4db78698c55
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Thu Feb 12 01:43:04 2015 +0100
soup-server: add soup_server_accept_iostream()
Allow a GIOStream to be accepted as new client connection by the
SoupServer. This is useful for clients that do not want to rely on
system sockets for example.
https://bugzilla.gnome.org/show_bug.cgi?id=744186
docs/reference/libsoup-2.4-sections.txt | 1 +
libsoup/libsoup-2.4.sym | 1 +
libsoup/soup-server.c | 60 +++++++++++++++++++++++++++++-
libsoup/soup-server.h | 6 +++
4 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index 5f4c513..e98476f 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -227,6 +227,7 @@ soup_server_listen_fd
soup_server_get_uris
soup_server_disconnect
soup_server_is_https
+soup_server_accept_iostream
<SUBSECTION>
SoupServerCallback
soup_server_add_handler
diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym
index 5fede3a..2e2b65e 100644
--- a/libsoup/libsoup-2.4.sym
+++ b/libsoup/libsoup-2.4.sym
@@ -363,6 +363,7 @@ soup_requester_get_type
soup_requester_new
soup_requester_request
soup_requester_request_uri
+soup_server_accept_iostream
soup_server_add_auth_domain
soup_server_add_handler
soup_server_disconnect
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 30dc4f9..70a46b8 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -1325,9 +1325,9 @@ socket_disconnected (SoupSocket *sock, SoupClientContext *client)
}
static void
-new_connection (SoupSocket *listener, SoupSocket *sock, gpointer user_data)
+soup_server_accept_socket (SoupServer *server,
+ SoupSocket *sock)
{
- SoupServer *server = user_data;
SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server);
SoupClientContext *client;
@@ -1339,6 +1339,62 @@ new_connection (SoupSocket *listener, SoupSocket *sock, gpointer user_data)
}
/**
+ * soup_server_accept_iostream:
+ * @server: a #SoupServer
+ * @stream: a #GIOStream
+ * @local_addr: (allow-none): the local #GSocketAddress associated with the @stream
+ * @remote_addr: (allow-none): the remote #GSocketAddress associated with the @stream
+ * @error: return location for a #GError
+ *
+ * Add a new client stream to the @server.
+ *
+ * Return value: %TRUE on success, %FALSE if the stream could not be
+ * accepted or any other error occurred (in which case @error will be
+ * set).
+ *
+ * Since: 2.50
+ **/
+gboolean
+soup_server_accept_iostream (SoupServer *server,
+ GIOStream *stream,
+ GSocketAddress *local_addr,
+ GSocketAddress *remote_addr,
+ GError **error)
+{
+ SoupSocket *sock;
+ SoupAddress *local = NULL, *remote = NULL;
+
+ if (local_addr)
+ local = soup_address_new_from_gsockaddr (local_addr);
+ if (remote_addr)
+ remote = soup_address_new_from_gsockaddr (remote_addr);
+
+ sock = g_initable_new (SOUP_TYPE_SOCKET, NULL, error,
+ "iostream", stream,
+ "local-address", local,
+ "remote-address", remote,
+ NULL);
+
+ g_clear_object (&local);
+ g_clear_object (&remote);
+
+ if (!sock)
+ return FALSE;
+
+ soup_server_accept_socket (server, sock);
+
+ return TRUE;
+}
+
+static void
+new_connection (SoupSocket *listener, SoupSocket *sock, gpointer user_data)
+{
+ SoupServer *server = user_data;
+
+ soup_server_accept_socket (server, sock);
+}
+
+/**
* soup_server_run_async:
* @server: a #SoupServer
*
diff --git a/libsoup/soup-server.h b/libsoup/soup-server.h
index 2cbd7d1..092cbf6 100644
--- a/libsoup/soup-server.h
+++ b/libsoup/soup-server.h
@@ -110,6 +110,12 @@ GSList *soup_server_get_listeners (SoupServer *server
void soup_server_disconnect (SoupServer *server);
+SOUP_AVAILABLE_IN_2_50
+gboolean soup_server_accept_iostream (SoupServer *server,
+ GIOStream *stream,
+ GSocketAddress *local_addr,
+ GSocketAddress *remote_addr,
+ GError **error);
/* Handlers and auth */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]