qutescheme: guess mimetype instead of 'text/html'

Since we're now using qute:// to serve files other than html
(see: pdfjs), it's a good idea to change the mimetype accordingly. This
also prevents warnings in the console, as QWebKit will complain e.g.
when stylesheets are served with 'text/html'.
This commit is contained in:
Daniel Schadt 2015-12-03 21:49:40 +01:00
parent 49ed04715e
commit c0b3160676

View File

@ -31,6 +31,7 @@ Module attributes:
import functools
import configparser
import mimetypes
from PyQt5.QtCore import pyqtSlot, QObject
from PyQt5.QtNetwork import QNetworkReply
@ -94,8 +95,11 @@ class QuteSchemeHandler(schemehandler.SchemeHandler):
return networkreply.ErrorNetworkReply(
request, str(e), QNetworkReply.ContentNotFoundError,
self.parent())
mimetype, _encoding = mimetypes.guess_type(request.url().fileName())
if mimetype is None:
mimetype = 'text/html'
return networkreply.FixedDataNetworkReply(
request, data, 'text/html', self.parent())
request, data, mimetype, self.parent())
class JSBridge(QObject):