souphttpsrc: ignore errors from HEAD request
authorThiago Santos <thiago.sousa.santos@collabora.com>
Thu, 11 Jul 2013 23:41:23 +0000 (20:41 -0300)
committerSebastian Dröge <slomo@circular-chaos.org>
Fri, 12 Jul 2013 08:01:26 +0000 (10:01 +0200)
HEAD requests are used to check the server headers to see if it
seekable. Ignore errors from those requests as they shouldn't be
critical.

https://bugzilla.gnome.org/show_bug.cgi?id=704053

ext/soup/gstsouphttpsrc.c

index 79f6109d468619ba4d393935cde62bd3a37e1009..b7f6de04573a4903aa15b096a0304d6c9ff994cc 100644 (file)
@@ -937,10 +937,15 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
     src->ret = GST_FLOW_CUSTOM_ERROR;
   } else if (G_UNLIKELY (src->session_io_status !=
           GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
-    /* FIXME: reason_phrase is not translated, add proper error message */
-    GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
-        ("%s", msg->reason_phrase),
-        ("libsoup status code %d", msg->status_code));
+    if (msg->method == SOUP_METHOD_HEAD) {
+      GST_DEBUG_OBJECT (src, "Ignoring error %d:%s during HEAD request",
+          msg->status_code, msg->reason_phrase);
+    } else {
+      /* FIXME: reason_phrase is not translated, add proper error message */
+      GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
+          ("%s", msg->reason_phrase),
+          ("libsoup status code %d", msg->status_code));
+    }
   }
   if (src->loop)
     g_main_loop_quit (src->loop);
@@ -1112,38 +1117,43 @@ static void
 gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src)
 {
   if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) {
-    switch (msg->status_code) {
-      case SOUP_STATUS_CANT_RESOLVE:
-      case SOUP_STATUS_CANT_RESOLVE_PROXY:
-        SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND,
-            _("Could not resolve server name."));
-        src->ret = GST_FLOW_ERROR;
-        break;
-      case SOUP_STATUS_CANT_CONNECT:
-      case SOUP_STATUS_CANT_CONNECT_PROXY:
-        SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
-            _("Could not establish connection to server."));
-        src->ret = GST_FLOW_ERROR;
-        break;
-      case SOUP_STATUS_SSL_FAILED:
-        SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
-            _("Secure connection setup failed."));
-        src->ret = GST_FLOW_ERROR;
-        break;
-      case SOUP_STATUS_IO_ERROR:
-        SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
-            _("A network error occured, or the server closed the connection "
-                "unexpectedly."));
-        src->ret = GST_FLOW_ERROR;
-        break;
-      case SOUP_STATUS_MALFORMED:
-        SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
-            _("Server sent bad data."));
-        src->ret = GST_FLOW_ERROR;
-        break;
-      case SOUP_STATUS_CANCELLED:
-        /* No error message when interrupted by program. */
-        break;
+    if (msg->method == SOUP_METHOD_HEAD) {
+      GST_DEBUG_OBJECT (src, "Ignoring error %d during HEAD request",
+          msg->status_code);
+    } else {
+      switch (msg->status_code) {
+        case SOUP_STATUS_CANT_RESOLVE:
+        case SOUP_STATUS_CANT_RESOLVE_PROXY:
+          SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND,
+              _("Could not resolve server name."));
+          src->ret = GST_FLOW_ERROR;
+          break;
+        case SOUP_STATUS_CANT_CONNECT:
+        case SOUP_STATUS_CANT_CONNECT_PROXY:
+          SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
+              _("Could not establish connection to server."));
+          src->ret = GST_FLOW_ERROR;
+          break;
+        case SOUP_STATUS_SSL_FAILED:
+          SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
+              _("Secure connection setup failed."));
+          src->ret = GST_FLOW_ERROR;
+          break;
+        case SOUP_STATUS_IO_ERROR:
+          SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
+              _("A network error occured, or the server closed the connection "
+                  "unexpectedly."));
+          src->ret = GST_FLOW_ERROR;
+          break;
+        case SOUP_STATUS_MALFORMED:
+          SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
+              _("Server sent bad data."));
+          src->ret = GST_FLOW_ERROR;
+          break;
+        case SOUP_STATUS_CANCELLED:
+          /* No error message when interrupted by program. */
+          break;
+      }
     }
   } else if (SOUP_STATUS_IS_CLIENT_ERROR (msg->status_code) ||
       SOUP_STATUS_IS_REDIRECTION (msg->status_code) ||