Implement case-insensitive matching

- mediatype strings are supposed to be case-insensitive. Ensure
  mediatype is normalized to lowercase, and that comparison mediatypes
  are as well prior to matching.