[totem] backend: Add helper to check HTTP status codes



commit 642b57b737e32d37852e9fbb01b2cb37ac17de54
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jun 29 19:24:14 2012 +0100

    backend: Add helper to check HTTP status codes
    
    So that we can get better error messages for those.

 src/backend/bacon-video-widget-gst-0.10.c |   38 +++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 46f4848..fe29a81 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -1528,6 +1528,44 @@ bvw_auth_reply_cb (GMountOperation      *op,
   }
 }
 
+static int
+bvw_get_http_error_code (GstMessage *err_msg)
+{
+  GError *err = NULL;
+  gchar *dbg = NULL;
+  int code = -1;
+
+  if (g_strcmp0 ("GstRTSPSrc", G_OBJECT_TYPE_NAME (err_msg->src)) != 0 &&
+      g_strcmp0 ("GstSoupHTTPSrc", G_OBJECT_TYPE_NAME (err_msg->src)) != 0)
+    return code;
+
+  gst_message_parse_error (err_msg, &err, &dbg);
+
+  /* Urgh! Check whether this is an auth error */
+  if (err == NULL || dbg == NULL)
+    goto done;
+  if (!is_error (err, RESOURCE, READ) &&
+      !is_error (err, RESOURCE, OPEN_READ))
+    goto done;
+
+  /* FIXME: Need to find a better way than parsing the plain text */
+  /* Keep in sync with bvw_error_from_gst_error() */
+  if (strstr (dbg, "400") != NULL)
+    code = 400;
+  if (strstr (dbg, "401") != NULL)
+    code = 401;
+  else if (strstr (dbg, "403") != NULL)
+    code = 403;
+  else if (strstr (dbg, "404") != NULL)
+    code = 404;
+
+done:
+  if (err != NULL)
+    g_error_free (err);
+  g_free (dbg);
+  return code;
+}
+
 /* returns TRUE if the error should be ignored */
 static gboolean
 bvw_check_missing_auth (BaconVideoWidget * bvw, GstMessage * err_msg)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]