Edgewall Software

Ticket #3456: mimetype-r3556.patch

File mimetype-r3556.patch, 0.8 KB (added by eblot, 2 years ago)

Use Trac get_mimetypes() to detect MIME type of static files

  • trac/web/api.py

     
    2727from trac.util import get_last_traceback 
    2828from trac.util.datefmt import http_date 
    2929from trac.web.href import Href 
     30from trac.mimeview.api import get_mimetype 
    3031 
    3132HTTP_STATUS = dict([(code, reason.title()) for code, (reason, description) 
    3233                    in BaseHTTPRequestHandler.responses.items()]) 
     
    388389            raise RequestDone 
    389390 
    390391        if not mimetype: 
    391             mimetype = mimetypes.guess_type(path)[0] or \ 
    392                        'application/octet-stream' 
     392            mimetype = get_mimetype(path) or 'application/octet-stream' 
    393393 
    394394        self.send_response(200) 
    395395        self.send_header('Content-Type', mimetype)