Hi,

On Thu, Mar 24, 2011 at 12:00 AM,  <n...@apache.org> wrote:
> When trying to identify a parser for a media type in AutoDetect and similar, 
> if the Parser
> claims to support an alias of the media type but not the canonical one (eg 
> someone
> changed the mimetype file but not the parser), then have the parser accepted 
> on the alias.

It would be good if changes like this were associated with a relevant
improvement issue in Jira. That way we can better track what was
changed and when.

> +            // Next up, look for one for its aliases
> +            SortedSet<MediaType> aliases = registry.getAliases(type);
> +            for (MediaType alias : aliases) {
> +               parser = map.get(alias);
> +               if (parser != null) {
> +                   return parser;
> +               }
> +            }

As an alternative solution, how about if we simply used
MediaTypeRegistry.normalize() in CompositeParser.getParsers()  to map
all supported types into their canonical versions. Then we wouldn't
need to duplicate these alias lookups elsewhere and things like
CompositeParser.getSupportedTypes() would automatically return
normalized type names.

BR,

Jukka Zitting

Reply via email to