Use regular system GnomeVFS 'http' method if it already supports seek().
authorshort <>
Mon, 17 Nov 2003 07:36:44 +0000 (07:36 +0000)
committershort <>
Mon, 17 Nov 2003 07:36:44 +0000 (07:36 +0000)
src/install/acquire/cabinet.c
src/install/acquire/microsoftcom.c

index 95465a3..ade7d80 100644 (file)
@@ -317,10 +317,37 @@ struct acquire_cabinet *r;
        r->offset=0;
        r->handlep=handlep;
        r->size=file_info->size;
-       acquire_cabinet_set_uri(r,uri);
        r->cabinet_done=0;
        r->cabinet_used=cabinet_used;
 
+       /* Replace 'http://' by 'httpcaptive://' if system 'http' does not support seek(). */
+       gnome_vfs_uri_ref(uri);
+       if (GNOME_VFS_ERROR_NOT_SUPPORTED==gnome_vfs_seek(
+                       *handlep,       /* handle */
+                       GNOME_VFS_SEEK_START,   /* whence */
+                       0)) {   /* offset */
+gchar *href;
+const gchar *href2;
+GnomeVFSURI *uri2;
+
+               href=gnome_vfs_uri_to_string(uri,GNOME_VFS_URI_HIDE_NONE);
+               if (strncmp(href,"http://",strlen("http://"))) {
+                       g_warning(_("Destination file URL not valid: %s"),href);
+                       goto href_done;
+                       }
+               href2=captive_printf_alloca("httpcaptive://%s",href+strlen("http://"));
+               if (!(uri2=gnome_vfs_uri_new(href2))) {
+                       g_warning(_("'httpcaptive' GnomeVFS method not supported; install package 'gnomevfs-httpcaptive'; URL: %s"),href2);
+                       goto href_done;
+                       }
+               gnome_vfs_uri_unref(uri);
+               uri=uri2;
+href_done:;
+               }
+
+       acquire_cabinet_set_uri(r,uri);
+       gnome_vfs_uri_unref(uri);
+
        return r;
 }
 
index 6459c6a..d754d8d 100644 (file)
@@ -50,7 +50,6 @@ int base_size;
 char *base_contents,*href_end;
 #endif
 char *href;
-const char *href2;
 GnomeVFSURI *uri;
 
 #ifdef MICROSOFTCOM_URL
@@ -69,13 +68,8 @@ GnomeVFSURI *uri;
 #else
        href=MICROSOFTDOWNLOAD_URL;
 #endif
-       if (strncmp(href,"http://",strlen("http://"))) {
-               g_warning(_("Destination file URL not valid: %s"),href);
-               goto fail_free_base_contents;
-               }
-       href2=captive_printf_alloca("httpcaptive://%s",href+strlen("http://"));
-       if (!(uri=gnome_vfs_uri_new(href2))) {
-               g_warning(_("Found destination file URL not parsable: %s"),href2);
+       if (!(uri=gnome_vfs_uri_new(href))) {
+               g_warning(_("Found destination file URL not parsable: %s"),href);
                goto fail_free_base_contents;
                }
 #ifdef MICROSOFTCOM_URL