[libsoup/wip/remove-deprecations: 29/49] Remove soup_session_connect_async() API
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/remove-deprecations: 29/49] Remove soup_session_connect_async() API
- Date: Tue, 30 Jun 2020 21:56:44 +0000 (UTC)
commit 091a5b2f350bbc6fc6a5ad08e3437fe32712cd4a
Author: Patrick Griffis <pgriffis igalia com>
Date: Tue Mar 10 20:45:30 2020 -0700
Remove soup_session_connect_async() API
The reasons for adding it no longer exist and it is unused API.
See also: d852881f1ab7d6107b2581d3a28d3529b85ea298
libsoup/soup-session.c | 154 ----------------------------------------
libsoup/soup-session.h | 18 -----
tests/connection-test.c | 183 ------------------------------------------------
3 files changed, 355 deletions(-)
---
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 9c8f629c..97995260 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -4733,157 +4733,3 @@ soup_session_websocket_connect_finish (SoupSession *session,
return g_task_propagate_pointer (G_TASK (result), error);
}
-
-/**
- * SoupSessionConnectProgressCallback:
- * @session: the #SoupSession
- * @event: a #GSocketClientEvent
- * @connection: the current state of the network connection
- * @user_data: the data passed to soup_session_connect_async().
- *
- * Prototype for the progress callback passed to soup_session_connect_async().
- *
- * Since: 2.62
- */
-
-typedef struct {
- SoupMessageQueueItem *item;
- SoupSessionConnectProgressCallback progress_callback;
- gpointer user_data;
-} ConnectAsyncData;
-
-static ConnectAsyncData *
-connect_async_data_new (SoupMessageQueueItem *item,
- SoupSessionConnectProgressCallback progress_callback,
- gpointer user_data)
-{
- ConnectAsyncData *data;
-
- soup_message_queue_item_ref (item);
-
- data = g_slice_new (ConnectAsyncData);
- data->item = item;
- data->progress_callback = progress_callback;
- data->user_data = user_data;
-
- return data;
-}
-
-static void
-connect_async_data_free (ConnectAsyncData *data)
-{
- soup_message_queue_item_unref (data->item);
-
- g_slice_free (ConnectAsyncData, data);
-}
-
-static void
-connect_async_message_network_event (SoupMessage *msg,
- GSocketClientEvent event,
- GIOStream *connection,
- GTask *task)
-{
- ConnectAsyncData *data = g_task_get_task_data (task);
-
- if (data->progress_callback)
- data->progress_callback (data->item->session, event, connection, data->user_data);
-}
-
-static void
-connect_async_message_finished (SoupMessage *msg,
- GTask *task)
-{
- ConnectAsyncData *data = g_task_get_task_data (task);
- SoupMessageQueueItem *item = data->item;
-
- if (!item->conn || item->error) {
- g_task_return_error (task, g_error_copy (item->error));
- } else {
- g_task_return_pointer (task,
- steal_connection (item->session, item),
- g_object_unref);
- }
- g_object_unref (task);
-}
-
-/**
- * soup_session_connect_async:
- * @session: a #SoupSession
- * @uri: a #SoupURI to connect to
- * @cancellable: a #GCancellable
- * @progress_callback: (allow-none) (scope async): a #SoupSessionConnectProgressCallback which
- * will be called for every network event that occurs during the connection.
- * @callback: (allow-none) (scope async): the callback to invoke when the operation finishes
- * @user_data: data for @progress_callback and @callback
- *
- * Start a connection to @uri. The operation can be monitored by providing a @progress_callback
- * and finishes when the connection is done or an error ocurred.
- *
- * Call soup_session_connect_finish() to get the #GIOStream to communicate with the server.
- *
- * Since: 2.62
- */
-void
-soup_session_connect_async (SoupSession *session,
- SoupURI *uri,
- GCancellable *cancellable,
- SoupSessionConnectProgressCallback progress_callback,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- SoupSessionPrivate *priv;
- SoupMessage *msg;
- SoupMessageQueueItem *item;
- ConnectAsyncData *data;
- GTask *task;
-
- g_return_if_fail (SOUP_IS_SESSION (session));
- g_return_if_fail (!SOUP_IS_SESSION_SYNC (session));
- priv = soup_session_get_instance_private (session);
- g_return_if_fail (priv->use_thread_context);
- g_return_if_fail (uri != NULL);
-
- task = g_task_new (session, cancellable, callback, user_data);
-
- msg = soup_message_new_from_uri (SOUP_METHOD_HEAD, uri);
- soup_message_set_flags (msg, SOUP_MESSAGE_NEW_CONNECTION);
- g_signal_connect_object (msg, "finished",
- G_CALLBACK (connect_async_message_finished),
- task, 0);
- if (progress_callback) {
- g_signal_connect_object (msg, "network-event",
- G_CALLBACK (connect_async_message_network_event),
- task, 0);
- }
-
- item = soup_session_append_queue_item (session, msg, TRUE, FALSE, NULL, NULL);
- item->connect_only = TRUE;
- data = connect_async_data_new (item, progress_callback, user_data);
- g_task_set_task_data (task, data, (GDestroyNotify) connect_async_data_free);
- soup_session_kick_queue (session);
- soup_message_queue_item_unref (item);
- g_object_unref (msg);
-}
-
-/**
- * soup_session_connect_finish:
- * @session: a #SoupSession
- * @result: the #GAsyncResult passed to your callback
- * @error: return location for a #GError, or %NULL
- *
- * Gets the #GIOStream created for the connection to communicate with the server.
- *
- * Return value: (transfer full): a new #GIOStream, or %NULL on error.
- *
- * Since: 2.62
- */
-GIOStream *
-soup_session_connect_finish (SoupSession *session,
- GAsyncResult *result,
- GError **error)
-{
- g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
- g_return_val_if_fail (g_task_is_valid (result, session), NULL);
-
- return g_task_propagate_pointer (G_TASK (result), error);
-}
diff --git a/libsoup/soup-session.h b/libsoup/soup-session.h
index dc2e22a6..d8e5ce9e 100644
--- a/libsoup/soup-session.h
+++ b/libsoup/soup-session.h
@@ -224,24 +224,6 @@ SoupWebsocketConnection *soup_session_websocket_connect_finish (SoupSession
GAsyncResult *result,
GError **error);
-typedef void (*SoupSessionConnectProgressCallback) (SoupSession *session,
- GSocketClientEvent event,
- GIOStream *connection,
- gpointer user_data);
-
-SOUP_AVAILABLE_IN_2_62
-void soup_session_connect_async (SoupSession *session,
- SoupURI *uri,
- GCancellable *cancellable,
- SoupSessionConnectProgressCallback progress_callback,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-SOUP_AVAILABLE_IN_2_62
-GIOStream *soup_session_connect_finish (SoupSession *session,
- GAsyncResult *result,
- GError **error);
-
G_END_DECLS
#endif /* __SOUP_SESSION_H__ */
diff --git a/tests/connection-test.c b/tests/connection-test.c
index 9b451176..dea95fd7 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -1007,188 +1007,6 @@ do_connection_event_test (void)
soup_test_session_abort_unref (session);
}
-typedef struct {
- GMainLoop *loop;
- GIOStream *stream;
- GError *error;
- const char *events;
-} ConnectTestData;
-
-static void
-connect_progress (SoupSession *session, GSocketClientEvent event, GIOStream *connection, ConnectTestData
*data)
-{
- soup_test_assert (*data->events == event_abbrevs[event],
- "Unexpected event: %s (expected %s)",
- event_names[event],
- event_name_from_abbrev (*data->events));
- data->events = data->events + 1;
-}
-
-static void
-connect_finished (SoupSession *session, GAsyncResult *result, ConnectTestData *data)
-{
- data->stream = soup_session_connect_finish (session, result, &data->error);
- g_main_loop_quit (data->loop);
-}
-
-static void
-do_one_connection_connect_test (SoupSession *session, SoupURI *uri, const char *response, const char *events)
-{
- ConnectTestData data = { NULL, NULL, NULL, events };
- static const char *request = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n";
- gsize bytes = 0;
- char buffer[128];
-
- data.loop = g_main_loop_new (NULL, FALSE);
- soup_session_connect_async (session, uri, NULL,
- (SoupSessionConnectProgressCallback)connect_progress,
- (GAsyncReadyCallback)connect_finished,
- &data);
- g_main_loop_run (data.loop);
-
- g_assert (G_IS_IO_STREAM (data.stream));
- g_assert_no_error (data.error);
- g_assert (g_output_stream_write_all (g_io_stream_get_output_stream (data.stream),
- request, strlen (request), &bytes, NULL, NULL));
- g_assert (g_input_stream_read_all (g_io_stream_get_input_stream (data.stream),
- buffer, sizeof (buffer), &bytes, NULL, NULL));
- buffer[strlen (response)] = '\0';
- g_assert_cmpstr (buffer, ==, response);
-
- while (*data.events) {
- soup_test_assert (!*data.events,
- "Expected %s",
- event_name_from_abbrev (*data.events));
- data.events++;
- }
-
- g_object_unref (data.stream);
- g_main_loop_unref (data.loop);
-}
-
-static void
-do_one_connection_connect_fail_test (SoupSession *session, SoupURI *uri, GQuark domain, gint code, const
char *events)
-{
- ConnectTestData data = { NULL, NULL, NULL, events };
-
- data.loop = g_main_loop_new (NULL, FALSE);
- soup_session_connect_async (session, uri, NULL,
- (SoupSessionConnectProgressCallback)connect_progress,
- (GAsyncReadyCallback)connect_finished,
- &data);
- g_main_loop_run (data.loop);
- g_main_loop_unref (data.loop);
-
- g_assert (!data.stream);
- g_assert_error (data.error, domain, code);
- g_clear_error (&data.error);
-
- while (*data.events) {
- soup_test_assert (!*data.events,
- "Expected %s",
- event_name_from_abbrev (*data.events));
- data.events++;
- }
-}
-
-static void
-do_connection_connect_test (void)
-{
- SoupSession *session;
- SoupURI *http_uri;
- SoupURI *https_uri = NULL;
- SoupURI *ws_uri;
- SoupURI *wss_uri = NULL;
- SoupURI *file_uri;
- SoupURI *wrong_http_uri;
- GProxyResolver *resolver;
-
- SOUP_TEST_SKIP_IF_NO_APACHE;
-
- session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
- NULL);
-
- debug_printf (1, " http\n");
- http_uri = soup_uri_new (HTTP_SERVER);
- do_one_connection_connect_test (session, http_uri,
- "HTTP/1.1 200 OK", "rRcCx");
-
- if (tls_available) {
- debug_printf (1, " https\n");
- https_uri = soup_uri_new (HTTPS_SERVER);
- do_one_connection_connect_test (session, https_uri,
- "HTTP/1.1 200 OK", "rRcCtTx");
- } else
- debug_printf (1, " https -- SKIPPING\n");
-
- debug_printf (1, " ws\n");
- ws_uri = soup_uri_new (HTTP_SERVER);
- ws_uri->scheme = SOUP_URI_SCHEME_WS;
- do_one_connection_connect_test (session, ws_uri,
- "HTTP/1.1 200 OK", "rRcCx");
-
- if (tls_available) {
- debug_printf (1, " wss\n");
- wss_uri = soup_uri_new (HTTPS_SERVER);
- do_one_connection_connect_test (session, wss_uri,
- "HTTP/1.1 200 OK", "rRcCtTx");
- } else
- debug_printf (1, " wss -- SKIPPING\n");
-
- debug_printf (1, " file\n");
- file_uri = soup_uri_new ("file:///foo/bar");
- do_one_connection_connect_fail_test (session, file_uri,
- G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
- "r");
-
- debug_printf (1, " wrong http (invalid port)\n");
- wrong_http_uri = soup_uri_new (HTTP_SERVER);
- wrong_http_uri->port = 1234;
- do_one_connection_connect_fail_test (session, wrong_http_uri,
- G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED,
- "rRcr"); /* FIXME: why r again? GLib bug? */
-
- resolver = g_simple_proxy_resolver_new (HTTP_PROXY, NULL);
- g_object_set (G_OBJECT (session),
- SOUP_SESSION_PROXY_RESOLVER, resolver,
- NULL);
- g_object_unref (resolver);
-
- debug_printf (1, " http with proxy\n");
- do_one_connection_connect_test (session, http_uri,
- "HTTP/1.1 403 Forbidden", "rRcCx");
-
- if (tls_available) {
- debug_printf (1, " https with proxy\n");
- do_one_connection_connect_test (session, https_uri,
- "HTTP/1.1 200 OK", "rRcCpPtTx");
- } else
- debug_printf (1, " https with proxy -- SKIPPING\n");
-
- debug_printf (1, " ws with proxy\n");
- do_one_connection_connect_test (session, ws_uri,
- "HTTP/1.1 403 Forbidden", "rRcCx");
-
- if (tls_available) {
- debug_printf (1, " wss with proxy\n");
- do_one_connection_connect_test (session, wss_uri,
- "HTTP/1.1 200 OK", "rRcCpPtTx");
- } else
- debug_printf (1, " wss with proxy -- SKIPPING\n");
-
- soup_uri_free (http_uri);
- if (https_uri)
- soup_uri_free (https_uri);
- soup_uri_free (ws_uri);
- if (wss_uri)
- soup_uri_free (wss_uri);
- soup_uri_free (file_uri);
- soup_uri_free (wrong_http_uri);
-
- soup_test_session_abort_unref (session);
-}
-
int
main (int argc, char **argv)
{
@@ -1210,7 +1028,6 @@ main (int argc, char **argv)
g_test_add_func ("/connection/non-idempotent", do_non_idempotent_connection_test);
g_test_add_func ("/connection/state", do_connection_state_test);
g_test_add_func ("/connection/event", do_connection_event_test);
- g_test_add_func ("/connection/connect", do_connection_connect_test);
ret = g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]