def _match_serializers_by_accept_headers(self, serializers,
                                             default_media_type):
        """Match serializer by `Accept` headers."""
        # Bail out fast if no accept headers were given.
        if len(request.accept_mimetypes) == 0:
            return serializers[default_media_type]

        # Determine best match based on quality.
        best_quality = -1
        best = None
        has_wildcard = False
        for client_accept, quality in request.accept_mimetypes:
            if quality <= best_quality:
                continue
            if client_accept == '*/*':
                has_wildcard = True
            for s in serializers:
                if s in ['*/*', client_accept] and quality > 0:
                    best_quality = quality
                    best = s

        # If no match found, but wildcard exists, them use default media
        # type.
        if best is None and has_wildcard:
            best = default_media_type

        if best is not None:
            return serializers[best]
        return None
Match serializer by `Accept` headers.