[totem-pl-parser] main: Try harder to get the mime-type for a remote file
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser] main: Try harder to get the mime-type for a remote file
- Date: Mon, 15 Nov 2010 11:52:11 +0000 (UTC)
commit 616a033529a7856dd04ad207cb2a4ebc65bd235e
Author: Bastien Nocera <hadess hadess net>
Date: Mon Nov 15 11:49:32 2010 +0000
main: Try harder to get the mime-type for a remote file
Trying to parse http://faif.us/feeds/cast-mp3/ will fail because
the web server only returns the data line-by-line.
https://bugzilla.gnome.org/show_bug.cgi?id=634770
plparse/tests/parser.c | 1 +
plparse/totem-pl-parser.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index a6863a5..1e36c74 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -206,6 +206,7 @@ test_parsability (void)
{ "http://live.hujjat.org:7860/main", FALSE, TRUE },
{ "http://www.comedycentral.com/sitewide/media_player/videoswitcher.jhtml?showid=934&category=/shows/the_daily_show/videos/headlines&sec=videoId%3D36032%3BvideoFeatureId%3D%3BpoppedFrom%3D_shows_the_daily_show_index.jhtml%3BisIE%3Dfalse%3BisPC%3Dtrue%3Bpagename%3Dmedia_player%3Bzyg%3D%27%2Bif_nt_zyg%2B%27%3Bspan%3D%27%2Bif_nt_span%2B%27%3Bdemo%3D%27%2Bif_nt_demo%2B%27%3Bbps%3D%27%2Bif_nt_bandwidth%2B%27%3Bgateway%3Dshows%3Bsection_1%3Dthe_daily_show%3Bsection_2%3Dvideos%3Bsection_3%3Dheadlines%3Bzyg%3D%27%2Bif_nt_zyg%2B%27%3Bspan%3D%27%2Bif_nt_span%2B%27%3Bdemo%3D%27%2Bif_nt_demo%2B%27%3Bera%3D%27%2Bif_nt_era%2B%27%3Bbps%3D%27%2Bif_nt_bandwidth%2B%27%3Bfla%3D%27%2Bif_nt_Flash%2B%27&itemid=36032&clip=com/dailyshow/headlines/10156_headline.wmv&mswmext=.asx", TRUE, TRUE },
{ TEST_SRCDIR "HackerMedley", TRUE, FALSE }, /* From https://bugzilla.redhat.com/show_bug.cgi?id=582850 and http://feeds.feedburner.com/HackerMedley */
+ { "http://faif.us/feeds/cast-mp3", TRUE, TRUE },
{ NULL, FALSE, FALSE }
};
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index ec32b70..7d0d33b 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -714,7 +714,7 @@ static char *
my_g_file_info_get_mime_type_with_data (GFile *file, gpointer *data, TotemPlParser *parser)
{
char *buffer;
- gssize bytes_read;
+ gsize bytes_read;
GFileInputStream *stream;
GError *error = NULL;
@@ -751,13 +751,13 @@ my_g_file_info_get_mime_type_with_data (GFile *file, gpointer *data, TotemPlPars
/* Read the whole thing, up to MIME_READ_CHUNK_SIZE */
buffer = g_malloc (MIME_READ_CHUNK_SIZE);
- bytes_read = g_input_stream_read (G_INPUT_STREAM (stream), buffer, MIME_READ_CHUNK_SIZE, NULL, &error);
- g_object_unref (G_INPUT_STREAM (stream));
- if (bytes_read == -1) {
+ if (g_input_stream_read_all (G_INPUT_STREAM (stream), buffer, MIME_READ_CHUNK_SIZE, &bytes_read, NULL, &error) == FALSE) {
+ g_object_unref (stream);
DEBUG(file, g_print ("Couldn't read data from '%s'\n", uri));
g_free (buffer);
return NULL;
}
+ g_object_unref (G_INPUT_STREAM (stream));
/* Empty file */
if (bytes_read == 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]