[libsoup] Temporarily re-add soup_client_context_* APIs
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Temporarily re-add soup_client_context_* APIs
- Date: Sat, 19 Sep 2020 22:41:56 +0000 (UTC)
commit 3a7b2039bb98d2ade49b04729f2be3acdff06fb5
Author: Patrick Griffis <pgriffis igalia com>
Date: Sun Feb 16 17:30:11 2020 -0800
Temporarily re-add soup_client_context_* APIs
This is heavily used by tests and will require more work to get
rid of.
libsoup/soup-server.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-
libsoup/soup-server.h | 9 ++++++++
2 files changed, 66 insertions(+), 1 deletion(-)
---
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 69428d48..43bcaed3 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -1768,6 +1768,34 @@ soup_server_get_uris (SoupServer *server)
**/
G_DEFINE_BOXED_TYPE (SoupClientContext, soup_client_context, soup_client_context_ref,
soup_client_context_unref)
+/**
+ * soup_client_context_get_socket:
+ * @client: a #SoupClientContext
+ *
+ * Retrieves the #SoupSocket that @client 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 (either by using weak references, or by
+ * connecting to the #SoupSocket::disconnected signal), so that you do
+ * not get fooled when the allocator reuses the memory address of a
+ * previously-destroyed socket to represent a new socket.
+ *
+ * Return value: (transfer none): the #SoupSocket that @client is
+ * associated with.
+ *
+ * Deprecated: use soup_client_context_get_gsocket(), which returns
+ * a #GSocket.
+ **/
+SoupSocket *
+soup_client_context_get_socket (SoupClientContext *client)
+{
+ g_return_val_if_fail (client != NULL, NULL);
+
+ return client->sock;
+}
+
/**
* soup_client_context_get_gsocket:
* @client: a #SoupClientContext
@@ -1794,6 +1822,28 @@ soup_client_context_get_gsocket (SoupClientContext *client)
return client->gsock;
}
+/**
+ * soup_client_context_get_address:
+ * @client: a #SoupClientContext
+ *
+ * Retrieves the #SoupAddress associated with the remote end
+ * of a connection.
+ *
+ * Return value: (nullable) (transfer none): the #SoupAddress
+ * associated with the remote end of a connection, it may be
+ * %NULL if you used soup_server_accept_iostream().
+ *
+ * Deprecated: Use soup_client_context_get_remote_address(), which returns
+ * a #GSocketAddress.
+ **/
+SoupAddress *
+soup_client_context_get_address (SoupClientContext *client)
+{
+ g_return_val_if_fail (client != NULL, NULL);
+
+ return soup_socket_get_remote_address (client->sock);
+}
+
/**
* soup_client_context_get_remote_address:
* @client: a #SoupClientContext
@@ -1869,7 +1919,6 @@ soup_client_context_get_host (SoupClientContext *client)
if (client->remote_ip)
return client->remote_ip;
- g_assert (client->gsock); /* FIXME: Always use gsock */
if (client->gsock) {
GSocketAddress *addr = soup_client_context_get_remote_address (client);
GInetAddress *iaddr;
@@ -1878,6 +1927,13 @@ soup_client_context_get_host (SoupClientContext *client)
return NULL;
iaddr = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (addr));
client->remote_ip = g_inet_address_to_string (iaddr);
+ } else {
+ SoupAddress *addr;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ addr = soup_client_context_get_address (client);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ client->remote_ip = g_strdup (soup_address_get_physical (addr));
}
return client->remote_ip;
diff --git a/libsoup/soup-server.h b/libsoup/soup-server.h
index 99ad4400..5873fee0 100644
--- a/libsoup/soup-server.h
+++ b/libsoup/soup-server.h
@@ -198,6 +198,15 @@ const char *soup_client_context_get_auth_user (SoupClientContext *clien
SOUP_AVAILABLE_IN_2_50
GIOStream *soup_client_context_steal_connection (SoupClientContext *client);
+/* Legacy API */
+
+SOUP_AVAILABLE_IN_2_4
+SOUP_DEPRECATED_IN_2_48
+SoupAddress *soup_client_context_get_address (SoupClientContext *client);
+SOUP_AVAILABLE_IN_2_4
+SOUP_DEPRECATED_IN_2_48
+SoupSocket *soup_client_context_get_socket (SoupClientContext *client);
+
G_END_DECLS
#endif /* __SOUP_SERVER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]