本文整理汇总了Python中django.http.request.HttpRequest.META['REMOTE_ADDR']方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.META['REMOTE_ADDR']方法的具体用法?Python HttpRequest.META['REMOTE_ADDR']怎么用?Python HttpRequest.META['REMOTE_ADDR']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.request.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.META['REMOTE_ADDR']方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_ip
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def test_get_ip(self):
request = HttpRequest()
request.META['REMOTE_ADDR'] = '1.2.3.4'
self.assertEqual(
get_ip_address(request),
'1.2.3.4'
)
示例2: get_request
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def get_request(self):
request = HttpRequest()
request.META['REMOTE_ADDR'] = '1.2.3.4'
request.method = 'POST'
request.session = SessionStore()
request._messages = default_storage(request)
request.user = AnonymousUser()
return request
示例3: setUp
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def setUp(self):
clean_db_datas()
self.request = generateHttpRequest()
self.assn = SmartPhoneAssn.all_objects.get(device_id=self.request.REQUEST['DCOM_DEVICE_ID'])
self.assn.user_type = 101
self.assn.push_token = 'test smartPhoneAssn'
self.assn.save(self.request)
env = Client()._base_environ()
request = HttpRequest()
request.META['REMOTE_ADDR'] = env['REMOTE_ADDR']
self.assn1_request = request
self.assn1 = SmartPhoneAssn()
self.assn1.user = self.request.user
self.assn1.user_type = 2
self.assn1.platform = 'iPhone'
self.assn1.push_token = 'test smartPhoneAssn1'
self.assn1.save(request)
示例4: get_request
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def get_request(self):
request = HttpRequest()
request.META['REMOTE_ADDR'] = '1.2.3.4'
request.META['HTTP_X_FORWARDED_FOR'] = '7.8.9.0'
return request
示例5: test_proxy
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def test_proxy(self):
request = HttpRequest()
request.META['REMOTE_ADDR'] = '7.8.9.0'
request.META['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'
middleware = ProxyMiddleware(self.get_response)
self.assertEqual(middleware(request), 'response')
示例6: test_direct
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def test_direct(self):
request = HttpRequest()
request.META['REMOTE_ADDR'] = '1.2.3.4'
middleware = ProxyMiddleware(self.get_response)
self.assertEqual(middleware(request), 'response')
示例7: get_request
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['REMOTE_ADDR'] [as 别名]
def get_request(self):
request = HttpRequest()
request.META['REMOTE_ADDR'] = '1.2.3.4'
return request