[maemo-commits] [maemo-commits] r8813 - projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Dec 19 11:23:20 EET 2006
Author: richard
Date: 2006-12-19 11:23:19 +0200 (Tue, 19 Dec 2006)
New Revision: 8813

Added:
   projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches/27-workaround-broken-http-servers.patch
Log:
Add patch for broken http servers.


Added: projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches/27-workaround-broken-http-servers.patch
===================================================================
--- projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches/27-workaround-broken-http-servers.patch	2006-12-19 09:14:14 UTC (rev 8812)
+++ projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches/27-workaround-broken-http-servers.patch	2006-12-19 09:23:19 UTC (rev 8813)
@@ -0,0 +1,81 @@
+Index: modules/http-neon-method.c
+===================================================================
+--- modules/http-neon-method.c	(revision 8808)
++++ modules/http-neon-method.c	(working copy)
+@@ -1819,6 +1819,41 @@ http_follow_redirect (HttpContext *conte
+ /* ************************************************************************** */
+ /* Http operations */
+ 
++/* Sends a HEAD/GET request where we are not interested in any information
++ * except headers. Some broken servers send the content for HEAD requests, so we
++ * always try to read to get rid of that by closing the connection, and for the
++ * case where this is used with GET as fallback for HEAD, we are also not
++ * interested in the data.
++ */
++static int
++dispatch_head_request (ne_request *req)
++{
++	gboolean must_close = FALSE;
++	char buffer[1];
++	size_t len;
++	int res;
++	
++	do {
++		res = ne_begin_request (req);
++		
++		if (NE_OK == res) {
++			len = ne_read_response_block (req, buffer, sizeof buffer);
++			must_close = (len > 0);
++		}
++
++		if (NE_OK == res) {
++			res = ne_end_request (req);
++		}
++	} while (NE_RETRY == res);
++
++	if (must_close) {
++		DEBUG_HTTP ("explictly closing connection");
++		ne_close_connection (ne_get_session (req));
++	}
++
++	return res;
++}
++
+ static GnomeVFSResult
+ http_get_file_info (HttpContext *context, GnomeVFSFileInfo *info)
+ {
+@@ -1897,9 +1932,18 @@ http_get_file_info (HttpContext *context
+ 
+  head_start:
+ 	req  = ne_request_create (context->session, "HEAD", context->path);
++	res = dispatch_head_request (req);
++	result = resolve_result (res, req);
+ 
+-	res = ne_request_dispatch (req);
+-
++	if (res == NE_ERROR || result == GNOME_VFS_ERROR_NOT_SUPPORTED) {
++		/* Assume that there was a broken server... fallback to GET. */
++		DEBUG_HTTP ("Fall back to GET request");
++		
++		ne_request_destroy (req);
++		req = ne_request_create (context->session, "GET", context->path);
++		res = dispatch_head_request (req);
++	}
++	
+ 	if (res == NE_REDIRECT) {
+ 		ne_request_destroy (req);
+ 		req = NULL;
+@@ -1930,13 +1974,6 @@ http_get_file_info (HttpContext *context
+ 		info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_TYPE;
+ 
+ 		std_headers_to_file_info (req, info);
+-		
+-		/* work-around for broken icecast server */
+-		if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE
+-		    && ! g_ascii_strcasecmp (info->mime_type, "audio/mpeg")) {
+-			ne_close_connection (ne_get_session (req));
+-		}
+-		
+ 	}
+ 	
+ 	ne_request_destroy (req);


More information about the maemo-commits mailing list