跳到主要内容

4. Discrete Media Type 值

五种离散顶层 媒体类型 是: text, image, audio, video 和 application.

4.1. Text Media Type​

text 媒体类型 用于以文本形式表示的信息.

4.1.1. 换行表示​

text 类型的内容被假定为面向行的. 换行必须使用 CRLF 序列表示.

4.1.2. Charset 参数​

text 类型最重要的参数是 charset 参数. 它指定用于表示文本的字符集.

常见字符集:

  • US-ASCII: 7 位 ASCII(默认)
  • UTF-8: Unicode UTF-8 编码(推荐)
  • ISO-8859-1: 西欧语言
  • GB2312, GBK, GB18030: 简体中文
  • Big5: 繁体中文
  • Shift_JIS, EUC-JP:日语

4.1.3. Plain 子类型​

text/plain 是最基本的 text 子类型, 表示纯文本.

Content-Type: text/plain; charset=UTF-8

4.1.4. 其他 Text 子类型​

  • text/html:HTML 文档
  • text/css:CSS 样式表
  • text/javascript:JavaScript 代码
  • text/csv:逗号分隔值
  • text/xml:XML 文档

4.2. Image Media Type​

image 媒体类型 用于传送静态 (非动画) 图形图像数据.

常见 子类型:

  • image/jpeg: JPEG 图像
  • image/png: PNG 图像
  • image/gif: GIF 图像 (可包含动画)
  • image/svg+xml: SVG 矢量图形
  • image/webp: WebP 图像
Content-Type: image/jpeg

4.3. Audio Media Type​

audio 媒体类型 用于传输音频或语音数据.

常见 子类型:

  • audio/mpeg: MP3 audio
  • audio/mp4: MP4 audio
  • audio/wav: WAV audio
  • audio/ogg: Ogg Vorbis
  • audio/webm: WebM audio
Content-Type: audio/mpeg

4.4. Video Media Type​

video 媒体类型 用于传输视频或动态图像数据, 可能带有音频.

常见 子类型:

  • video/mp4: MP4 video
  • video/mpeg: MPEG video
  • video/ogg: Ogg Theora
  • video/webm: WebM video
Content-Type: video/mp4

4.5. Application Media Type​

application 媒体类型 用于不适合其他类型的离散数据.

4.5.1. Octet-Stream 子类型​

application/octet-stream 用于 子类型 未指定或未知的二进制数据.

Content-Type: application/octet-stream

4.5.2. PostScript 子类型​

application/postscript 用于 PostScript 程序.

4.5.3. 其他 Application 子类型​

  • application/pdf:PDF 文档
  • application/json: JSON data
  • application/xml: XML data
  • application/zip: ZIP 压缩文件
  • application/javascript: JavaScript
  • application/x-www-form-urlencoded: Form data

摘要:

类型用途常见 子类型
text文本数据plain, html, css
image图像jpeg, png, gif
audio音频mpeg, wav, ogg
video视频mp4, mpeg, webm
application其他pdf, json, zip, octet-stream