Search code examples
http-headersmime-types

Is it correct to specify HTTP response Content-Type as image/*?


I'm curious whether sending Content-Type: image/* in a HTTP response is correct. I know it's advisable to specify the exact MIME type but I'd like to hear if I can use such a header as a fallback when I know it's an image but I don't know its type.


Solution

  • I don't see any evidence that you can or should use wildcards in Content-Type.

    RFC 7231 does allow wildcards like that in the Accept header, where you're indicating a range of acceptable content types. The definition of Content-Type does not give any special meaning to the * character, and image/* is not listed as a registered type.

    If you cannot identify the media type accurately, you should just leave off the header entirely.