def get_content_type(request):
    """Return the MIME content type giving the request

    Return `None` if unknown.
    """
    if hasattr(request, 'content_type'):
        conttype = request.content_type
    else:
        header = request.META.get('CONTENT_TYPE', None)
        if not header:
            return None
        conttype = header.partition(';')[0]
    return conttype
