Network: What is MIME TYPE?

Source: Internet
Author: User

Tutorial

Https://www.cnblogs.com/jsean/articles/1610265.html
Https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types
Recently in reading Golang source code, see mime.go This file, a little to read.

About MIME

MIME, mutipurpose Internet Mail Extensions, Multipurpose Internet Mailbox extension. MIME is an Internet standard that describes the message content type. When it was created, it was designed to attach multimedia data when sending e-mail, so that the mail client processes it according to its type. The MIME TYPE is now supported by the HTTP protocol, allowing HTTP to transmit a wide variety of files.

Browser and Mime-type

The browser uses the MIME TYE, which is the media type of the resource, to decide in what form to display the data.

The media type is usually communicated via the HTTP protocol by the Content-type in the Web server request header to the browser data type, such as:

Content-Type: text/HTML

Indicates that the content is a text/html type, which is a hypertext file. Note that it must be "text/html" rather than "Html/text". Because MIME is negotiated by the IETF organization, it is posted on the Internet in the form of an RFC.

Types of Customizations

It is important to note that only some formats that are widely used on the internet get a MIME Type, and if it is a client-defined format, it can usually start with application/x-.

There is a dedicated organization in the Internet to revise the MIME standards, but because the internet is growing too fast, many applications use the X-based method in the category to identify that the category has not become a standard, such as X-gzip,x-tar.

In fact, it is not the standard does not matter, as long as the client and the server can recognize this format. Custom standards are used on the app side to ensure data security.

The MIME type is related to the suffix of the document, so the server uses the document's suffix to differentiate the MIME types of different files, and the server must specify the correspondence between the file suffix and the MIME type. When the client receives data from the server, it simply receives the data stream from the server and does not know the name of the document, so the server needs to use additional information to tell the client about the MIME type of the program data. The server will first send the following two lines of MIME identification information, which is not part of a real data file.

Context-type: text/html

Note that the second behavior is a space, which is required, and the purpose of using this empty line is to split the MIME information away from the real data content.

MIME type syntax and common classifications

Common structure:type/subtype
MIME types are not case sensitive, but are usually lowercase in the traditional notation.
Classification

category Description Typical Types
Text Indicates that it is plain text Text/plain, text/html, Text/css, Text/javascript
Image Represents an image that does not include a video file, but includes a dynamic diagram Image/gif/image/png, Image/jpeg, Image/bmp, IMAGE/WEBP
Audio Audio files Audio/midi, Audio/mpeg, AUDIO/WEBM, Audio/ogg, Audio/wav,
Video Represents a video file VIDEO/WEBM, Video/ogg
Application Represents some kind of binary data APPLICATION/OCTET-STREAM,/PKCS12, Application/vnd.mspowerpoint, Application/xhtml+xml, Application/xml, Application/pdf,application/json

If there is no specific subtype for the text file type, use Text/plain if there is no specific or known subtype for a similar binary file, use Application/octet-stream.

Important MIME Types

Text/plain
The text file default value, meaning is unknown text file, the browser thinks is can show directly.

Text/css
Any CSS file that is intended to be interpreted on a Web page must be set to the Text/css file. If the server sets the MIME type to Text/plain or Application/octet-stream, in which case the file is not recognized by the browser as a CSS file and is ignored directly.

Text/html
This format should be used for all HTML content.

Type of picture

MIME Type type of picture
Image/gif GIF Pictures
Image/jpeg JPEG pictures
Image/png PNG pictures
Image/svg+xml SVG pictures (vector image)

There are non-MIME types, but more generic icon types, Image/x-icon

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.