def _utf8_encoded_json(request):
    """Checks if content of the request is defined to be utf-8 encoded json.

    'Content-type' header should be set to 'application/json;
    charset=utf-8'.  The function allows whitespaces around the two
    segments an is case-insensitive.
    """
    content_type = request.META.get('CONTENT_TYPE', '')
    parts = content_type.split(';')
    if (len(parts) != 2 or
        parts[0].strip().lower() != 'application/json' or
        parts[1].strip().lower() != 'charset=utf-8'):
        return False
    return True