Index: daemon/gvfsbackendhttp.c
===================================================================
--- daemon/gvfsbackendhttp.c	(revision 1946)
+++ daemon/gvfsbackendhttp.c	(working copy)
@@ -546,6 +546,56 @@
 
   g_print ("basename:%s\n", basename);
 
+  /* use Content-Disposition instead of basename if provided */
+  text = soup_message_headers_get (msg->response_headers,
+				   "Content-Disposition");
+  if (text)
+    {
+      char *start = NULL;
+      char *end = NULL;
+
+      start = strstr (text, "; filename=");
+      if (start != NULL)
+	{
+	  start += strlen ("; filename=");
+	  
+	  /* handle quoted-string and raw forms of the filename */
+	  if (start[0] == '\"')
+	    {
+	      start++;
+	      end = strchr (start, '\"');
+	    }
+	  else
+	    {
+	      end = strchr (start, ';');
+	      if (end == NULL)
+		{
+		  end = start + strlen (start);
+		}
+	    }
+
+	  if (start != NULL && end != NULL)
+	    {
+	      char *tmp;
+	      char *bn;
+	      
+	      /* ignore everything but the basename from the header */
+	      tmp = strndup (start, end - start);
+	      bn = g_path_get_basename (tmp);
+	      g_free (tmp);
+	      if (strcmp (bn, ".") != 0)
+		{
+		  g_free (basename);
+		  basename = bn;
+		}
+	      else
+		{
+		  g_free (bn);
+		}
+	    }
+	}
+    }
+
   /* read http/1.1 rfc, until then we copy the local files
    * behaviour */ 
   if (basename != NULL &&
