Beispiel #1
0
def test_parse_content_type():
    from respite.utils import parse_content_type

    assert_equal(('text/html', 'ISO-8859-1'), parse_content_type('text/html'))
    assert_equal(('text/html', 'ISO-8859-4'), parse_content_type('text/html; charset=ISO-8859-4'))

    assert_equal(('application/json', 'UTF-8'), parse_content_type('application/json'))
    assert_equal(('application/json', 'ISO-8859-1'), parse_content_type('application/json; charset=ISO-8859-1'))
    def process_request(self, request):
        content_type = request.META.get('CONTENT_TYPE')

        if content_type and parse_content_type(content_type)[0] == 'application/json':
            data = json.loads(request.raw_post_data)

            if request.method in ['POST', 'PUT', 'PATCH']:
                setattr(request, request.method, QueryDict(urlencode(data)))
    def process_request(self, request):
        if "CONTENT_TYPE" in request.META:
            content_type, encoding = parse_content_type(request.META["CONTENT_TYPE"])

            if content_type == "application/json":
                data = json.loads(request.body, encoding)

                if request.method in ["POST", "PUT", "PATCH"]:
                    setattr(request, request.method, NestedQueryDict(data))
Beispiel #4
0
    def process_request(self, request):
        if 'CONTENT_TYPE' in request.META:
            content_type, encoding = parse_content_type(request.META['CONTENT_TYPE'])

            if content_type == 'application/json':
                data = json.loads(request.raw_post_data, encoding)

                if request.method in ['POST', 'PUT', 'PATCH']:
                    setattr(request, request.method, QueryDict(urlencode(data)))
Beispiel #5
0
    def process_request(self, request):
        if 'CONTENT_TYPE' in request.META:
            content_type, encoding = parse_content_type(request.META['CONTENT_TYPE'])

            if content_type == 'application/json':
                data = json.loads(request.body, encoding)

                if request.method in ['POST', 'PUT', 'PATCH']:
                    setattr(request, request.method, NestedQueryDict(data))
Beispiel #6
0
def test_parse_content_type():
    from respite.utils import parse_content_type

    assert_equal(('text/html', 'ISO-8859-1'), parse_content_type('text/html'))
    assert_equal(('text/html', 'ISO-8859-4'), parse_content_type('text/html; charset=ISO-8859-4'))
Beispiel #7
0
def test_parse_content_type():
    from respite.utils import parse_content_type

    assert_equal(('text/html', 'ISO-8859-1'), parse_content_type('text/html'))
    assert_equal(('text/html', 'ISO-8859-4'),
                 parse_content_type('text/html; charset=ISO-8859-4'))