[gupnp/gupnp-1.4] ServiceProxy: Do transport errors in call_finish
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp/gupnp-1.4] ServiceProxy: Do transport errors in call_finish
- Date: Sat, 8 Jan 2022 09:20:32 +0000 (UTC)
commit d5e5bd25b9f745b16f0b4542f8df2bdf25240969
Author: Jens Georg <mail jensge org>
Date: Sat Jan 8 10:16:16 2022 +0100
ServiceProxy: Do transport errors in call_finish
Fixes #63
libgupnp/gupnp-service-proxy-action.c | 2 ++
libgupnp/gupnp-service-proxy.c | 64 ++++++++++++++++-------------------
tests/test-bugs.c | 5 ++-
3 files changed, 35 insertions(+), 36 deletions(-)
---
diff --git a/libgupnp/gupnp-service-proxy-action.c b/libgupnp/gupnp-service-proxy-action.c
index ea61986..f089152 100644
--- a/libgupnp/gupnp-service-proxy-action.c
+++ b/libgupnp/gupnp-service-proxy-action.c
@@ -78,6 +78,7 @@ check_action_response (G_GNUC_UNUSED GUPnPServiceProxy *proxy,
switch (action->msg->status_code) {
case SOUP_STATUS_OK:
case SOUP_STATUS_INTERNAL_SERVER_ERROR:
+ // This indicates a SOAP error that needs to be evaluated
break;
default:
_gupnp_error_set_server_error (error, action->msg);
@@ -96,6 +97,7 @@ check_action_response (G_GNUC_UNUSED GUPnPServiceProxy *proxy,
GUPNP_SERVER_ERROR_INVALID_RESPONSE,
"Could not parse SOAP response");
} else {
+ // INTERNALL_SERVER_ERROR was not a SOAP error but something else
g_set_error_literal
(error,
GUPNP_SERVER_ERROR,
diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index bcf9439..6fb0e10 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -731,56 +731,47 @@ action_task_got_response (SoupSession *session,
GTask *task = G_TASK (user_data);
GUPnPServiceProxyAction *action = (GUPnPServiceProxyAction *) g_task_get_task_data (task);
+ // Re-send the message with method M-POST and s-SOAPAction
+ if (msg->status_code == SOUP_STATUS_METHOD_NOT_ALLOWED &&
+ g_str_equal ("POST", msg->method)) {
+ update_message_after_not_allowed (msg);
+ gupnp_service_proxy_action_queue_task (task);
+
+ return;
+ }
+
+ if (action->cancellable != NULL && action->cancellable_connection_id != 0) {
+ g_cancellable_disconnect (action->cancellable,
+ action->cancellable_connection_id);
+ action->cancellable_connection_id = 0;
+ }
+
+ if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) {
+ g_task_return_new_error (
+ task,
+ GUPNP_SERVER_ERROR,
+ GUPNP_SERVER_ERROR_OTHER,
+ "Server does not allow any POST messages");
+ g_object_unref (task);
+ }
+
switch (msg->status_code) {
case SOUP_STATUS_CANCELLED:
- if (action->cancellable != NULL && action->cancellable_connection_id != 0) {
- g_cancellable_disconnect (action->cancellable,
- action->cancellable_connection_id);
- action->cancellable_connection_id = 0;
- }
-
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CANCELLED,
"Action message was cancelled");
- g_object_unref (task);
break;
-
- case SOUP_STATUS_METHOD_NOT_ALLOWED:
- if (g_str_equal (msg->method, "POST")) {
- update_message_after_not_allowed (msg);
- gupnp_service_proxy_action_queue_task (task);
-
- } else {
- if (action->cancellable != NULL && action->cancellable_connection_id != 0) {
- g_cancellable_disconnect (action->cancellable,
- action->cancellable_connection_id);
- action->cancellable_connection_id = 0;
- }
-
- g_task_return_new_error (task,
- GUPNP_SERVER_ERROR,
- GUPNP_SERVER_ERROR_OTHER,
- "Server does not allow any POST messages");
- g_object_unref (task);
- }
- break;
-
default:
- if (action->cancellable != NULL && action->cancellable_connection_id != 0) {
- g_cancellable_disconnect (action->cancellable,
- action->cancellable_connection_id);
- action->cancellable_connection_id = 0;
- }
-
g_task_return_pointer (task,
g_task_get_task_data (task),
NULL);
- g_object_unref (task);
break;
}
+
+ g_object_unref (task);
}
static void
@@ -2118,6 +2109,9 @@ gupnp_service_proxy_call_action_async (GUPnPServiceProxy *proxy,
* Finish an asynchronous call initiated with
* gupnp_service_proxy_call_action_async().
*
+ * Note: This will only signalize transport errors to the caller, such as the action being cancelled
+ * or lost connection etc. SOAP call errors are only returned by gupnp_service_proxy_action_get() and such.
+ *
* Returns: (nullable) (transfer none): %NULL, if the call had an error, the action otherwise.
* Since: 1.2.0
*/
diff --git a/tests/test-bugs.c b/tests/test-bugs.c
index 24cf1fc..1ae48eb 100644
--- a/tests/test-bugs.c
+++ b/tests/test-bugs.c
@@ -745,7 +745,10 @@ on_ping (GObject *object, GAsyncResult *res, gpointer user_data)
res,
&error);
- g_assert_null (action);
+ g_assert_nonnull (action);
+ g_assert_no_error (error);
+
+ gupnp_service_proxy_action_get_result (action, &error, NULL);
g_assert_error (error, GUPNP_SERVER_ERROR, GUPNP_SERVER_ERROR_OTHER);
g_error_free (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]