将 HTTP 响应 Content-Type 指定为 image/* 是否正确?
Is it correct to specify HTTP response Content-Type as image/*?
我很好奇在 HTTP 响应中发送 Content-Type: image/*
是否正确。我知道指定确切的 MIME 类型是明智的,但我想知道当我知道它是图像但我不知道它的类型时是否可以使用这样的 header 作为后备。
我没有看到任何证据表明您可以或应该在 Content-Type
中使用通配符。
RFC 7231 确实允许在 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.
中使用通配符
如果您不能准确识别媒体类型,您应该完全不使用 header。
我很好奇在 HTTP 响应中发送 Content-Type: image/*
是否正确。我知道指定确切的 MIME 类型是明智的,但我想知道当我知道它是图像但我不知道它的类型时是否可以使用这样的 header 作为后备。
我没有看到任何证据表明您可以或应该在 Content-Type
中使用通配符。
RFC 7231 确实允许在 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.
如果您不能准确识别媒体类型,您应该完全不使用 header。