瀏覽代碼

change of content-type header

Kamil Endruszkiewicz 8 年之前
父節點
當前提交
648f911aad

+ 4 - 4
frameworks/Python/tornado/benchmark_config.json

@@ -22,7 +22,7 @@
       "os": "Linux",
       "database_os": "Linux",
       "display_name": "Tornado",
-      "notes": "CPython 2.7",
+      "notes": "",
       "versus": "tornado"
     },
     "pypy": {
@@ -46,7 +46,7 @@
       "os": "Linux",
       "database_os": "Linux",
       "display_name": "Tornado",
-      "notes": "Pypy",
+      "notes": "",
       "versus": "tornado"
     },
     "postgresql-raw": {
@@ -68,7 +68,7 @@
       "os": "Linux",
       "database_os": "Linux",
       "display_name": "Tornado",
-      "notes": "CPython 2.7",
+      "notes": "",
       "versus": "tornado"
     },
     "py3": {
@@ -92,7 +92,7 @@
       "os": "Linux",
       "database_os": "Linux",
       "display_name": "Tornado",
-      "notes": "CPython 3.4",
+      "notes": "",
       "versus": "tornado"
     }
   }]

+ 5 - 2
frameworks/Python/tornado/commons.py

@@ -14,13 +14,16 @@ class BaseHandler(tornado.web.RequestHandler):
 class PlainHandler(BaseHandler):
 
     def set_default_headers(self):
-        self.set_header("Content-Type", 'text/plain')
+        self.set_header("Content-Type", "text/plain")
 
+class HtmlHandler(BaseHandler):
+    def set_default_headers(self):
+        self.set_header("Content-Type", "text/html")
 
 class JsonHandler(BaseHandler):
 
     def set_default_headers(self):
-        self.set_header("Content-Type", "application/json; charset=UTF-8")
+        self.set_header("Content-Type", "application/json")
 
 
 class PlaintextHelloWorldHandler(PlainHandler):

+ 2 - 2
frameworks/Python/tornado/server_py2.py

@@ -9,7 +9,7 @@ import tornado.httpserver
 from random import randint
 from tornado import gen
 from tornado.options import options
-from commons import JsonHandler, JsonHelloWorldHandler, PlaintextHelloWorldHandler, BaseHandler
+from commons import JsonHandler, JsonHelloWorldHandler, PlaintextHelloWorldHandler, HtmlHandler
 
 
 options.define('port', default=8888, type=int, help="Server port")
@@ -79,7 +79,7 @@ class UpdateHandler(JsonHandler):
         self.finish(json.dumps(worlds))
 
 
-class FortuneHandler(BaseHandler):
+class FortuneHandler(HtmlHandler):
     @gen.coroutine
     def get(self):
         fortunes = []

+ 2 - 2
frameworks/Python/tornado/server_py3.py

@@ -8,7 +8,7 @@ import tornado.httpserver
 
 from random import randint
 from tornado.options import options
-from commons import JsonHandler, JsonHelloWorldHandler, PlaintextHelloWorldHandler
+from commons import JsonHandler, JsonHelloWorldHandler, PlaintextHelloWorldHandler, HtmlHandler
 from tornado.ioloop import IOLoop
 
 IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
@@ -78,7 +78,7 @@ class UpdateHandler(JsonHandler):
         self.finish(json.dumps(worlds))
 
 
-class FortuneHandler(JsonHandler):
+class FortuneHandler(HtmlHandler):
     async def get(self):
         fortunes = []