Internet media type

1. 背景

1.1 media type简介

Internet media type,最初被称为MIME type,是Multipurpose Internet Mail Extension的简写,它将非ASCII码的信息进行重构以便能够通过互联网传播,比如图像、音频、视频等文件,现在很多邮箱的客户端都开始支持MIME协议了。同样,浏览器也支持MIME,所以我们可以上网浏览视频、图片等非HTML 结构的数据。1
一个media type包含至少两方面,type、subtype以及一些可选的参数。比如,text子类型会有一个指定字节编码的参数,multipart子类型在两个parts之间会定义个界限。

1.2 media type类型

下面列出一些注册的media的类型,后面的章节会介绍子类型和字节编码:
- Type application: Multipurpose files
- Type audio: Audio
- Type image
- Type message
- Type model: 3D models
- Type multipart: Archives and other objects made of more than one part
- Type text: Human-readable text and source code
- Type video: Video
- Type vnd: Vendor Specific Files
- Type x: Non-standard files
- Type x-pkcs: PKCS standard files

2. 常用类型的子类型

这里列出三个现在比较常用的类型的子类型:
1. Type application: Multipurpose files
- application/EDI-X12: EDI X12 data; Defined in RFC 1767
- application/EDIFACT: EDI EDIFACT data; Defined in RFC 1767
- application/json: JavaScript Object Notation JSON; Defined in RFC 4627
- application/javascript: JavaScript; Defined in RFC 4329 but not accepted in IE 8 or earlier
- application/octet-stream: Arbitrary binary data.
- application/ogg: Ogg, a multimedia bitstream container format; Defined in RFC 5334
- application/pdf: Portable Document Format
- application/postscript: PostScript; Defined in RFC 2046
- application/soap+xml: SOAP; Defined by RFC 3902
- application/xhtml+xml: XHTML; Defined by RFC 3236
- application/xml-dtd: DTD files; Defined by RFC 3023
- application/zip: ZIP archive files
2. Type multipart: Archives and other objects made of more than one part
- multipart/mixed: MIME E-mail; Defined in RFC 2045 and RFC 2046
- multipart/alternative: MIME E-mail; Defined in RFC 2045 and RFC 2046
- multipart/related: MIME E-mail; Defined in RFC 2387 and used by MHTML (HTML mail)
- multipart/form-data: MIME Webform; Defined in RFC 2388
- multipart/signed: Defined in RFC 1847
- multipart/encrypted: Defined in RFC 1847
3. Type text: Human-readable text and source code
- text/cmd: commands; subtype resident in Gecko browsers like FireFox 3.5
- text/css: Cascading Style Sheets; Defined in RFC 2318
- text/csv: Comma-separated values; Defined in RFC 4180
- text/html: HTML; Defined in RFC 2854
- text/javascript (Obsolete): JavaScript
- text/plain: Textual data; Defined in RFC 2046 and RFC 3676
- text/xml: Extensible Markup Language; Defined in RFC 3023
其中,HTML forms提供三种编码方法,如下所示,application/x-www-form-urlencoded更像是一个添加在URL后端的一个询问字符串;multipart/form-data更加复杂,但是允许在数据中包含整个文件;text/plain在HTML5中引入的,一般只用于debugging。总之,当一个表单中包含文件上传时用multipart/form-data,否则用默认的application/x-www-form-urlencoded,本文会对这几种类型分别作出叙述。
1. application/x-www-form-urlencoded (the default)
2. multipart/form-data
3. text/plain

3. 本文分析内容安排

  • application/x-www-form-urlencoded
  • multipart/form-data
  • text/plain

4. application/x-www-form-urlencoded

5. multipart/form-data

5.1

5.2

6. Distribution运行案例分析

7. 总结

8. 作者介绍

梁明远,国防科大并行与分布式计算国家重点实验室应届研究生,14年入学伊始便开始接触docker,准备在余下的读研时间在docker相关开源社区贡献自己的代码,毕业后准备继续从事该方面研究。邮箱:[email protected]

9. 参考文献

  1. http://wasen.net/downloads/MIMETypeCollection.pdf ↩

你可能感兴趣的:(html,MIME,form-data,media-type)