Changeset 66b76d in indico


Ignore:
Timestamp:
04/08/11 15:15:01 (2 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
79bea23
Parents:
0b9955f
git-author:
Pedro Ferreira <jose.pedro.ferreira@…> (04/08/11 15:14:15)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (04/08/11 15:15:01)
Message:

[IMP] Use X-Send-File for all files

  • Attachments included;
Location:
indico
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/webinterface/rh/fileAccess.py

    r34f211 r66b76d  
    7070                pass 
    7171            self._req.headers_out["Content-Disposition"] = '%s; filename="%s"' % (dispos, self._file.getFileName()) 
    72             return self._file.readBin() 
     72 
     73            if cfg.getUseXSendFile(): 
     74                # X-Send-File support makes it easier, just let the web server 
     75                # do all the heavy lifting 
     76                return self._req.send_x_file(self._file.getFilePath()) 
     77            else: 
     78                return self._file.readBin() 
    7379        else: 
    7480            p = files.WPMinutesDisplay(self, self._file ) 
  • indico/web/wsgi/indico_wsgi_file_handler.py

    r657bd6 r66b76d  
    196196        return ret 
    197197 
    198  
    199198    if Config.getInstance().getUseXSendFile(): 
    200  
    201199        ## If XSendFile is supported by the server, let's use it. 
    202200        if os.path.exists(fullpath): 
    203  
    204             if fullname is None: 
    205                 fullname = os.path.basename(fullpath) 
    206             req.headers_out["Content-Disposition"] = 'inline; filename="%s"' % fullname.replace('"', '\\"') 
    207             req.headers_out["X-Sendfile"] = fullpath 
    208             if mime is None: 
    209                 (mime, encoding) = _mimes.guess_type(fullpath) 
    210                 if mime is None: 
    211                     mime = "application/octet-stream" 
    212             req.content_type = mime 
    213  
    214             return "" 
     201            return req.send_x_file(fullpath, fullname, mime) 
    215202        else: 
    216203            raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND 
     204 
     205    # otherwise, send file the "traditional" way 
    217206 
    218207    headers = get_normalized_headers(req.headers_in) 
  • indico/web/wsgi/indico_wsgi_handler.py

    r9bd9b1 r66b76d  
    460460        return self.__bytes_sent 
    461461 
     462    def send_x_file(self, fullpath, fullname=None, mime=None): 
     463        """ 
     464        Sends a file using X-Send-File 
     465        """ 
     466        if fullname is None: 
     467            fullname = os.path.basename(fullpath) 
     468        self.headers_out["Content-Disposition"] = 'inline; filename="%s"' % fullname.replace('"', '\\"') 
     469        self.headers_out["X-Sendfile"] = fullpath 
     470 
     471        if mime is None: 
     472            from indico.web.wsgi.indico_wsgi_file_handler import _mimes 
     473            (mime, encoding) = _mimes.guess_type(fullpath) 
     474            if mime is None: 
     475                mime = "application/octet-stream" 
     476        self.content_type = mime 
     477 
     478        return "" 
     479 
    462480    def set_content_length(self, content_length): 
    463481        if content_length is not None: 
Note: See TracChangeset for help on using the changeset viewer.