souphttpsrc: error out properly when receiving data along with an error status
authorNorbert Waschbuesch <nwaschbu@opentv.com>
Fri, 22 Jun 2012 21:56:52 +0000 (21:56 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Tue, 1 Jan 2013 19:11:42 +0000 (19:11 +0000)
When receiving an error code from the http server, such as 404,
data might be sent along with it, like a web page. We don't want
to output that data in this case, and we also want to pass the
FLOW_ERROR return back to the base class, so it can stop properly.

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

ext/soup/gstsouphttpsrc.c

index a5702a5..451bc62 100644 (file)
@@ -804,6 +804,17 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
         ("Server does not accept Range HTTP header, URL: %s", src->location));
     src->ret = GST_FLOW_ERROR;
   }
+
+  /* If we are going to error out, stop all processing right here, so we
+   * don't output any data (such as an error html page), and return
+   * GST_FLOW_ERROR from the create function instead of having
+   * got_chunk_cb overwrite src->ret with FLOW_OK again. */
+  if (src->ret == GST_FLOW_ERROR) {
+    gst_soup_http_src_session_pause_message (src);
+
+    if (src->loop)
+      g_main_loop_quit (src->loop);
+  }
 }
 
 /* Have body. Signal EOS. */