commit 7e5a1703836c883b5501142a7e1e8027b9a15662
parent a68eff592f68c8e1a899e1b3a2b1dd1e6667c203
Author: Sheng <webmaster0115@gmail.com>
Date: Tue, 16 Oct 2018 16:15:39 +0800
Added head method IndexHandler
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/tests/test_app.py b/tests/test_app.py
@@ -613,3 +613,18 @@ class TestAppNotFoundHandler(OtherTestBase):
response.headers['Server'], self.custom_headers['Server']
)
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)
diff --git a/webssh/handler.py b/webssh/handler.py
@@ -288,6 +288,9 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
else:
future.set_result(worker)
+ def head(self):
+ pass
+
def get(self):
self.render('index.html', debug=self.debug)