def _match_mask(mask, ctype):
    """
    Determine if a content type mask matches a given content type.

    :param mask: The content type mask, taken from the Accept
                 header.
    :param ctype: The content type to match to the mask.
    """

    # Handle the simple cases first
    if '*' not in mask:
        return ctype == mask
    elif mask == '*/*':
        return True
    elif not mask.endswith('/*'):
        return False

    mask_major = mask[:-2]
    ctype_major = ctype.split('/', 1)[0]
    return ctype_major == mask_major
Determine if a content type mask matches a given content type.

    :param mask: The content type mask, taken from the Accept
                 header.
    :param ctype: The content type to match to the mask.