Added head method IndexHandler

pull/38/head
Sheng 2018-10-16 16:15:39 +08:00
parent a68eff592f
commit 7e5a170383
2 changed files with 18 additions and 0 deletions

View File

@ -613,3 +613,18 @@ class TestAppNotFoundHandler(OtherTestBase):
response.headers['Server'], self.custom_headers['Server'] response.headers['Server'], self.custom_headers['Server']
) )
self.assertIn(b'404: Not Found', response.body) self.assertIn(b'404: Not Found', response.body)
class TestAppHeadRequest(OtherTestBase):
def test_with_index_path(self):
response = self.fetch('/', method='HEAD')
self.assertEqual(response.code, 200)
def test_with_ws_path(self):
response = self.fetch('/ws', method='HEAD')
self.assertEqual(response.code, 405)
def test_with_not_found_path(self):
response = self.fetch('/notfound', method='HEAD')
self.assertEqual(response.code, 404)

View File

@ -288,6 +288,9 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
else: else:
future.set_result(worker) future.set_result(worker)
def head(self):
pass
def get(self): def get(self):
self.render('index.html', debug=self.debug) self.render('index.html', debug=self.debug)