提交 c0839358 编写于 作者: P Paul Tremberth

Merge pull request #1771 from orangain/secure-cookies

[MRG+1] PY3: Implement some attributes of WrappedRequest required in Python 3
......@@ -137,13 +137,29 @@ class WrappedRequest(object):
"""
return self.request.meta.get('is_unverifiable', False)
# python3 uses request.unverifiable
def get_origin_req_host(self):
return urlparse_cached(self.request).hostname
# python3 uses attributes instead of methods
@property
def full_url(self):
return self.get_full_url()
@property
def host(self):
return self.get_host()
@property
def type(self):
return self.get_type()
@property
def unverifiable(self):
return self.is_unverifiable()
def get_origin_req_host(self):
return urlparse_cached(self.request).hostname
@property
def origin_req_host(self):
return self.get_origin_req_host()
def has_header(self, name):
return name in self.request.headers
......
......@@ -14,12 +14,15 @@ class WrappedRequestTest(TestCase):
def test_get_full_url(self):
self.assertEqual(self.wrapped.get_full_url(), self.request.url)
self.assertEqual(self.wrapped.full_url, self.request.url)
def test_get_host(self):
self.assertEqual(self.wrapped.get_host(), urlparse(self.request.url).netloc)
self.assertEqual(self.wrapped.host, urlparse(self.request.url).netloc)
def test_get_type(self):
self.assertEqual(self.wrapped.get_type(), urlparse(self.request.url).scheme)
self.assertEqual(self.wrapped.type, urlparse(self.request.url).scheme)
def test_is_unverifiable(self):
self.assertFalse(self.wrapped.is_unverifiable())
......@@ -32,6 +35,7 @@ class WrappedRequestTest(TestCase):
def test_get_origin_req_host(self):
self.assertEqual(self.wrapped.get_origin_req_host(), 'www.example.com')
self.assertEqual(self.wrapped.origin_req_host, 'www.example.com')
def test_has_header(self):
self.assertTrue(self.wrapped.has_header('content-type'))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册