当前位置: 首页>>代码示例>>Python>>正文


Python HttpRequest.META['REMOTE_ADDR']方法代码示例

本文整理汇总了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'
     )
开发者ID:dekoza,项目名称:weblate,代码行数:9,代码来源:test_request.py

示例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
开发者ID:nijel,项目名称:weblate,代码行数:10,代码来源:test_ratelimit.py

示例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)
开发者ID:DongHuaLu,项目名称:mdcom,代码行数:20,代码来源:test_utils.py

示例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
开发者ID:daleathan,项目名称:weblate,代码行数:7,代码来源:test_request.py

示例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')
开发者ID:dekoza,项目名称:weblate,代码行数:8,代码来源:test_middleware.py

示例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')
开发者ID:dekoza,项目名称:weblate,代码行数:7,代码来源:test_middleware.py

示例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
开发者ID:daleathan,项目名称:weblate,代码行数:6,代码来源:test_ratelimit.py


注:本文中的django.http.request.HttpRequest.META['REMOTE_ADDR']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。