summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackendhttp.c
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2011-05-08 15:53:26 +0200
committerChristian Kellner <gicmo@gnome.org>2011-05-08 15:53:26 +0200
commitfb8deae57304a921a736c4ad932928bee614a16e (patch)
tree86026913714cd1ae509a7ecc793c991b7eac769b /daemon/gvfsbackendhttp.c
parenta2a2fe70666618062148f5cbf0ca5e7f1eedfa0a (diff)
downloadgvfs-fb8deae57304a921a736c4ad932928bee614a16e.tar.gz
http: use Content-Disposition filename if available
Set edit/displayname based on the filename in the Content-Disposition header if available. Based on a patch from Mike Gratton <mike@vee.net>. Fixes bug 551298
Diffstat (limited to 'daemon/gvfsbackendhttp.c')
-rw-r--r--daemon/gvfsbackendhttp.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/daemon/gvfsbackendhttp.c b/daemon/gvfsbackendhttp.c
index fd01ad81..d983b593 100644
--- a/daemon/gvfsbackendhttp.c
+++ b/daemon/gvfsbackendhttp.c
@@ -558,13 +558,33 @@ file_info_from_message (SoupMessage *msg,
GFileInfo *info,
GFileAttributeMatcher *matcher)
{
- const SoupURI *uri;
- const char *text;
- char *basename;
- char *ed_name = NULL;
+ const char *text;
+ GHashTable *params;
+ char *basename;
+ char *ed_name;
- uri = soup_message_get_uri (msg);
- basename = http_uri_get_basename (uri->path);
+ basename = ed_name = NULL;
+
+ /* prefer the filename from the Content-Disposition (rfc2183) header
+ if one if present. See bug 551298. */
+ if (soup_message_headers_get_content_disposition (msg->response_headers,
+ NULL, &params))
+ {
+ const char *name = g_hash_table_lookup (params, "filename");
+
+ if (name)
+ basename = g_strdup (name);
+
+ g_hash_table_destroy (params);
+ }
+
+ if (basename == NULL)
+ {
+ const SoupURI *uri;
+
+ uri = soup_message_get_uri (msg);
+ basename = http_uri_get_basename (uri->path);
+ }
g_debug ("basename:%s\n", basename);