Ticket #3556: 0001-Automatically-download-attachment-files-SL-3556.patch

File 0001-Automatically-download-attachment-files-SL-3556.patch, 1.5 KB (added by humitos, 12 years ago)
  • browser.py

    From bfd50c1d86068c09651a576edd84fcd491d20f7a Mon Sep 17 00:00:00 2001
    Message-Id: <bfd50c1d86068c09651a576edd84fcd491d20f7a.1336104522.git.humitos@gmail.com>
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Fri, 4 May 2012 01:08:34 -0300
    Subject: [PATCH Browse] Automatically download "attachment" files SL #3556
    
    Check for "attachment" in Content-Disposition header and download the
    file automatically if it matches. This is a RFC specification.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     browser.py |   13 +++++++++++++
     1 files changed, 13 insertions(+), 0 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index c0bb7bc..bf046a2 100644
    a b class Browser(WebKit.WebView): 
    532532
    533533    def __mime_type_policy_cb(self, webview, frame, request, mimetype,
    534534                              policy_decision):
     535
     536        # We have to download the file if the Content-Disposition
     537        # header is "attachment"
     538        network_response = frame.get_network_response()
     539        if network_response:
     540            message = network_response.get_message()
     541            if message:
     542                content_disposition = message.props.\
     543                    response_headers.get_content_disposition()
     544                if content_disposition == 'attachment':
     545                    policy_decision.download()
     546                    return True
     547
    535548        if mimetype == 'application/pdf':
    536549            self.emit('open-pdf', request.get_uri())
    537550            return False