aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2009-12-09 00:08:15 +0800
committerGustavo Noronha Silva <gns@gnome.org>2009-12-09 00:10:16 +0800
commit1acaa540531f9ed3b33f87e10f0817b8c8ffd988 (patch)
treee427b3358680a7953228948bf36c37a3cd996410 /embed
parentc29cb6688dd71a282ac8079657076415ae3d05a8 (diff)
downloadgsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.tar
gsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.tar.gz
gsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.tar.bz2
gsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.tar.lz
gsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.tar.xz
gsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.tar.zst
gsoc2013-epiphany-1acaa540531f9ed3b33f87e10f0817b8c8ffd988.zip
Use new WebKit API to respect the Content-Disposition header
This allows us to perform downloads when the server tells us to do so, even for types WebKit supports. This fixes downloading GMail attachments. Bug #598605
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-web-view.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index c525ab1c2..09172b423 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -969,6 +969,7 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view,
gpointer user_data)
{
EphyWebViewDocumentType type;
+ gboolean should_download;
g_return_val_if_fail (mime_type, FALSE);
@@ -996,8 +997,35 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view,
/* If WebKit can't handle the mime type start the download
process */
+ should_download = !webkit_web_view_can_show_mime_type (web_view, mime_type);
+
+ /* Make sure we respect the Content-Disposition header */
+ if (!should_download) {
+ WebKitNetworkResponse *response = webkit_web_frame_get_network_response (frame);
+ SoupMessage *message = NULL;
+
+ if (response) {
+ message = webkit_network_response_get_message (response);
+ }
+
+ if (message) {
+ char *disposition = NULL;
+
+ soup_message_headers_get_content_disposition (message->response_headers,
+ &disposition,
+ NULL);
+
+ if (disposition) {
+ should_download = g_str_equal (disposition, "attachment");
+ g_free (disposition);
+ }
+ }
+
+ g_object_unref (response);
+ }
+
/* FIXME: need to use ephy_file_check_mime if auto-downloading */
- if (!webkit_web_view_can_show_mime_type (web_view, mime_type)) {
+ if (should_download) {
GObject *single;
const char *uri;
gboolean handled = FALSE;