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


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

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


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

示例1: test_resolver

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import META['HTTP_ACCEPT'] [as 别名]
    def test_resolver(self):
        request = HttpRequest()
        request.method = 'GET'
        request.META['HTTP_ACCEPT'] = '*/*'

        response = self.b(request)
        self.assertEqual(response.content, '[{"id": 1}, {"id": 2}]')
开发者ID:bruth,项目名称:django-restlib,代码行数:9,代码来源:default.py

示例2: test_options

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import META['HTTP_ACCEPT'] [as 别名]
    def test_options(self):
        request = HttpRequest()
        request.method = 'OPTIONS'
        request.META['HTTP_ACCEPT'] = 'application/json'

        response = self.a(request)
        self.assertEqual(response['Allow'], 'OPTIONS')
开发者ID:bruth,项目名称:django-restlib,代码行数:9,代码来源:default.py

示例3: test_json_includes_allow_header

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import META['HTTP_ACCEPT'] [as 别名]
    def test_json_includes_allow_header(self):
        class TestAllowActionResource(Resource):
            def get_actions(self):
                return { 'delete': Action(method='DELETE', attributes=None) }

        request = HttpRequest()
        request.META['HTTP_ACCEPT'] = 'application/json'
        response = TestAllowActionResource().get(request)

        self.assertEqual(response['Allow'], 'HEAD, GET, DELETE')
开发者ID:IwanJaya,项目名称:polls-api,代码行数:12,代码来源:tests.py

示例4: test_mimetype

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import META['HTTP_ACCEPT'] [as 别名]
    def test_mimetype(self):
        request = HttpRequest()
        request.method = 'GET'
        request.META['HTTP_ACCEPT'] = '*/*'

        self.b(request)
        self.assertEqual(request.accepttype, 'application/json')

        request = HttpRequest()
        request.method = 'PUT'
        request.META['CONTENT_TYPE'] = 'application/json; charset=utf-8'
        request._raw_post_data = '{"name": "Sally Doe", "age": null}'

        self.b(request)
        self.assertEqual(request.contenttype, 'application/json')
        self.assertTrue(hasattr(request, 'PUT'))
开发者ID:bruth,项目名称:django-restlib,代码行数:18,代码来源:default.py

示例5: test_webp_support_true

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import META['HTTP_ACCEPT'] [as 别名]
 def test_webp_support_true(self):
     request = HttpRequest()
     request.META['HTTP_ACCEPT'] =\
         'text/html,application/xhtml+xml,application/xml;' \
         'q=0.9,image/webp,*/*;q=0.8'
     assert webp_support(request) == {'webp_compatible': True}
开发者ID:tmiller02,项目名称:django-webp-converter,代码行数:8,代码来源:test_context_processors.py

示例6: test_webp_support_false

# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import META['HTTP_ACCEPT'] [as 别名]
 def test_webp_support_false(self):
     request = HttpRequest()
     request.META['HTTP_ACCEPT'] =\
         'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
     assert webp_support(request) == {'webp_compatible': False}
开发者ID:tmiller02,项目名称:django-webp-converter,代码行数:7,代码来源:test_context_processors.py


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