本文整理汇总了Python中django.http.request.HttpRequest.META['HTTP_X_FORWARDED_FOR']方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.META['HTTP_X_FORWARDED_FOR']方法的具体用法?Python HttpRequest.META['HTTP_X_FORWARDED_FOR']怎么用?Python HttpRequest.META['HTTP_X_FORWARDED_FOR']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.request.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.META['HTTP_X_FORWARDED_FOR']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_request
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['HTTP_X_FORWARDED_FOR'] [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
示例2: test_proxy
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META['HTTP_X_FORWARDED_FOR'] [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')