mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
httpserver: Explicitely define the charset.
This commit is contained in:
parent
1a71fa2d81
commit
74db03177f
@ -55,6 +55,7 @@ class RequestNotHandled(Exception):
|
|||||||
|
|
||||||
DEFAULT_TEMPLATES = {
|
DEFAULT_TEMPLATES = {
|
||||||
'index.html': """\
|
'index.html': """\
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
@ -70,7 +71,9 @@ DEFAULT_TEMPLATES = {
|
|||||||
</body>
|
</body>
|
||||||
</html>""",
|
</html>""",
|
||||||
'generic/error.html': """\
|
'generic/error.html': """\
|
||||||
<html>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>%(title)s</title>
|
<title>%(title)s</title>
|
||||||
<link rel="stylesheet" href="/default.css" />
|
<link rel="stylesheet" href="/default.css" />
|
||||||
@ -207,7 +210,7 @@ class SupyHTTPRequestHandler(BaseHTTPRequestHandler):
|
|||||||
if self.path == '/':
|
if self.path == '/':
|
||||||
callback = SupyIndex()
|
callback = SupyIndex()
|
||||||
elif self.path in ('/robots.txt',):
|
elif self.path in ('/robots.txt',):
|
||||||
callback = Static('text/plain')
|
callback = Static('text/plain; charset=utf-8')
|
||||||
elif self.path in ('/default.css',):
|
elif self.path in ('/default.css',):
|
||||||
callback = Static('text/css')
|
callback = Static('text/css')
|
||||||
elif self.path == '/favicon.ico':
|
elif self.path == '/favicon.ico':
|
||||||
@ -264,7 +267,7 @@ class SupyHTTPServerCallback(object):
|
|||||||
|
|
||||||
def doGet(self, handler, path, *args, **kwargs):
|
def doGet(self, handler, path, *args, **kwargs):
|
||||||
handler.send_response(400)
|
handler.send_response(400)
|
||||||
self.send_header('Content_type', 'text/plain; charset=utf-8')
|
self.send_header('Content-Type', 'text/plain; charset=utf-8; charset=utf-8')
|
||||||
self.send_header('Content-Length', len(self.defaultResponse))
|
self.send_header('Content-Length', len(self.defaultResponse))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(self.defaultResponse.encode())
|
self.wfile.write(self.defaultResponse.encode())
|
||||||
@ -286,7 +289,7 @@ class Supy404(SupyHTTPServerCallback):
|
|||||||
trained to help you in such a case.""")
|
trained to help you in such a case.""")
|
||||||
def doGet(self, handler, path, *args, **kwargs):
|
def doGet(self, handler, path, *args, **kwargs):
|
||||||
handler.send_response(404)
|
handler.send_response(404)
|
||||||
self.send_header('Content_type', 'text/plain; charset=utf-8')
|
self.send_header('Content-Type', 'text/plain; charset=utf-8; charset=utf-8')
|
||||||
self.send_header('Content-Length', len(self.response))
|
self.send_header('Content-Length', len(self.response))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
response = self.response
|
response = self.response
|
||||||
@ -310,7 +313,7 @@ class SupyIndex(SupyHTTPServerCallback):
|
|||||||
['<a href="/%s/">%s</a>' % (x,y.name) for x,y in plugins])
|
['<a href="/%s/">%s</a>' % (x,y.name) for x,y in plugins])
|
||||||
response = get_template('index.html') % {'list': plugins}
|
response = get_template('index.html') % {'list': plugins}
|
||||||
handler.send_response(200)
|
handler.send_response(200)
|
||||||
self.send_header('Content_type', 'text/html')
|
self.send_header('Content-Type', 'text/html; charset=utf-8')
|
||||||
self.send_header('Content-Length', len(response))
|
self.send_header('Content-Length', len(response))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(response)
|
self.wfile.write(response)
|
||||||
@ -320,7 +323,7 @@ class Static(SupyHTTPServerCallback):
|
|||||||
fullpath = True
|
fullpath = True
|
||||||
name = 'static'
|
name = 'static'
|
||||||
defaultResponse = _('Request not handled')
|
defaultResponse = _('Request not handled')
|
||||||
def __init__(self, mimetype='text/plain'):
|
def __init__(self, mimetype='text/plain; charset=utf-8'):
|
||||||
super(Static, self).__init__()
|
super(Static, self).__init__()
|
||||||
self._mimetype = mimetype
|
self._mimetype = mimetype
|
||||||
def doGet(self, handler, path):
|
def doGet(self, handler, path):
|
||||||
@ -359,7 +362,7 @@ class Favicon(SupyHTTPServerCallback):
|
|||||||
else:
|
else:
|
||||||
response = _('No favicon set.')
|
response = _('No favicon set.')
|
||||||
handler.send_response(404)
|
handler.send_response(404)
|
||||||
self.send_header('Content-type', 'text/plain')
|
self.send_header('Content-type', 'text/plain; charset=utf-8')
|
||||||
self.send_header('Content-Length', len(response))
|
self.send_header('Content-Length', len(response))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
|
Loading…
Reference in New Issue
Block a user