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


Python HttpRequest.META方法代码示例

本文整理汇总了Python中django.http.request.HttpRequest.META方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.META方法的具体用法?Python HttpRequest.META怎么用?Python HttpRequest.META使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http.request.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.META方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_with_server_name

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_server_name(self):
     request = HttpRequest()
     request.META = {
         'SERVER_NAME': 'example.com',
         'SERVER_PORT': 80
     }
     self.assertEqual(Site.find_for_request(request), self.site)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:9,代码来源:test_sites.py

示例2: test_with_x_forwarded_host

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_x_forwarded_host(self):
     with self.settings(USE_X_FORWARDED_HOST=True):
         request = HttpRequest()
         request.META = {'HTTP_X_FORWARDED_HOST': 'example.com', 'SERVER_PORT': 80}
         self.assertEqual(Site.find_for_request(request), self.site)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:7,代码来源:test_sites.py

示例3: test_with_host

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_host(self):
     request = HttpRequest()
     request.META = {'HTTP_HOST': 'example.com', 'SERVER_PORT': 80}
     self.assertEqual(Site.find_for_request(request), self.site)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:6,代码来源:test_sites.py

示例4: test_with_unknown_host

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_unknown_host(self):
     request = HttpRequest()
     request.META = {'HTTP_HOST': 'unknown.com', 'SERVER_PORT': 80}
     self.assertEqual(Site.find_for_request(request), self.default_site)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:6,代码来源:test_sites.py

示例5: test_with_server_name

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_server_name(self):
     request = HttpRequest()
     request.META = {"SERVER_NAME": "example.com", "SERVER_PORT": 80}
     self.assertEqual(Site.find_for_request(request), self.site)
开发者ID:Frankie-666,项目名称:wagtail,代码行数:6,代码来源:test_sites.py

示例6: test_with_x_forwarded_host

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_x_forwarded_host(self):
     with self.settings(USE_X_FORWARDED_HOST=True):
         request = HttpRequest()
         request.META = {"HTTP_X_FORWARDED_HOST": "example.com"}
         self.assertEqual(Site.find_for_request(request), self.site)
开发者ID:Frankie-666,项目名称:wagtail,代码行数:7,代码来源:test_sites.py

示例7: test_with_unknown_host

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_unknown_host(self):
     request = HttpRequest()
     request.META = {"HTTP_HOST": "unknown.com"}
     self.assertEqual(Site.find_for_request(request), self.default_site)
开发者ID:Frankie-666,项目名称:wagtail,代码行数:6,代码来源:test_sites.py

示例8: test_with_host

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_with_host(self):
     request = HttpRequest()
     request.META = {"HTTP_HOST": "example.com"}
     self.assertEqual(Site.find_for_request(request), self.site)
开发者ID:Frankie-666,项目名称:wagtail,代码行数:6,代码来源:test_sites.py

示例9: test_token_fail__mismatched

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_token_fail__mismatched(self):
     request = HttpRequest()
     request.META = {'HTTP_TOKEN': 'Banana'}
     response = function_for_testing(request, 'echome')
     self.assertEqual(response.status_code, 400)
     self.assertEqual(response.content, 'Token is required/mismatched.')
开发者ID:prontodev,项目名称:ban2stats,代码行数:8,代码来源:test_token_required.py

示例10: test_token_success

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_token_success(self):
     request = HttpRequest()
     request.META = {'HTTP_TOKEN': 'oTbCmV71i2Lg5wQMSsPEFKGJ0Banana'}
     result = function_for_testing(request, 'echome')
     self.assertEqual(result, 'echome')
开发者ID:prontodev,项目名称:ban2stats,代码行数:7,代码来源:test_token_required.py

示例11: test_send_verification_email

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
 def test_send_verification_email(self, send):
     req = HttpRequest()
     req.META = {"HTTP_HOST": "toto.com"}
     self.presta.send_verification_email(req)
     self.assertTrue(send.called)
     self.assertEqual(Key.objects.filter(claimed_by=self.presta.user, claimed=None).count(), 1)
开发者ID:huguesmayolle,项目名称:famille,代码行数:8,代码来源:test_models.py


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