Content-type description indicates the type arrangement of HTTP request headers _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
Tags gtar
The browser determines how to display the returned message body Content based on Content-Type. The following describes the Content-type, that is, the Type of the HTTP request header, if you are interested in content-type, you must know in advance what it is and what it is.

The HTTP protocol (RFC2616) uses the request/response model. The client sends a request to the server. The request header contains the request method, URI, Protocol version, and message structure similar to MIME containing the request modifier, customer information, and content. The server responds with a status line. The corresponding content includes the version of the Message Protocol, and the server information, entity metadata, and possible entity content are added to the success or error code.

Generally, an HTTP message consists of a starting line, one or more header fields, an empty line that is only the end of the header field, and an optional message body. The HTTP header includes four parts: Common headers, request headers, response headers, and object headers. Each header field consists of a domain name, a colon (:), and a domain value. The domain name is case-insensitive. You can add any number of space characters before the Domain value. The header field can be expanded to multiple rows. At least one space or Tab character is used at the beginning of each line.

Request messages and response messages can both contain entity information. entity information is generally composed of entity header fields and entities. The object header contains the original information about the object, object headers include Allow, Content-Base, Content-Encoding, Content-Language, Content-Length, Content-Location, Content-MD5, Content-Range, Content-Type, Etag, Expires, Last -Modified and extension-header.
Content-Type is a very important part of the returned message, indicating the MIME Type of the subsequent document. Content-Type: [type]/[subtype]; parameter. For example, the most common one is text/html, which means that the returned content is of the text type, and the text is in HTML format. In principle, the browser determines how to display the returned message body Content based on Content-Type.

Type has the following form

Text: indicates the standardized representation of Text information. Text messages can be in multiple character sets or formats;

Multipart: connects multiple parts of the message body to form a message. These parts can be different types of data;

Application: used to transmit Application data or binary data;

Message: Used to package an E-mail Message;

Image: used to transmit static Image data;

Audio: used to transmit Audio or Audio data;

Video: used to transmit dynamic image data. It can be a Video data format edited together with audio.

Subtype is used to specify the type details. The set of content-type/subtype pairs and related parameters will increase over time. To ensure that these values are developed in an orderly and open state, MIME uses Internet Assigned Numbers Authority (IANA) as the central registration mechanism to manage these values.

Parameter can be used to specify additional information. In more cases, it is used to specify the charset parameter for text encoding methods such as text/plain and text/htm. MIME defines the default subtype Based on the type. When the client cannot determine the subtype of the message, the message is treated as the default subtype for processing. Text is text/plain by default, Application is application/octet-stream by default, and Multipart is considered multipart/mixed by default. For IE 6 browser, if the Type in Content-Type is different from the actual message body Type, it will analyze the actual Type based on the Type in the Content, common image formats such as JPG and GIF can be correctly identified, regardless of what is written in Content-Type.
If Content-Type specifies a Type that can be directly opened by the browser, the browser will directly open its Content and display it. If it is associated with other application types, in this case, you need to find the registration information about this type in the registry. If you allow direct opening without asking, the associated application will be called up directly to open the file, however, if it cannot be opened directly, you will be asked if it is enabled. For a type that is not associated with any application, ie does not know how to open it. In this case, IE6 will treat it as XML and try to open it.

To download an object, add the following content to the http header:

Fprintf (file, "Content-Disposition: attachment; filename = \" % s \ "\ r \ n", fileName );

After testing, html, pdf, gif, and other files originally opened on the webpage can be downloaded normally.

'Hqx' => 'application/mac-binhex40 ',
'Cpt' => 'application/mac-compactpro ',
'Doc' => 'application/msword ',
'Bin' => 'application/octet-stream ',
'Dms '=> 'application/octet-stream ',
'Lha' => 'application/octet-stream ',
'Lzh '=> 'application/octet-stream ',
'Exe '=> 'application/octet-stream ',
'Class' => 'application/octet-stream ',
'So' => 'application/octet-stream ',
'Dll '=> 'application/octet-stream ',
'Oda '=> 'application/oda ',
'Pdf '=> 'application/pdf ',
'Ai' => 'application/postscript ',
'Eps '=> 'application/postscript ',
'Ps '=> 'application/postscript ',
'Smi' => 'application/smil ',
'Smil '=> 'application/smil ',
'Mfa' => 'application/vnd. mfa ',
'Xls '=> 'application/vnd. ms-excel ',
'Ppt '=> 'application/vnd. ms-powerpoint ',
'Wbxml' => 'application/vnd. wap. wbxml ',
'Wmlc' => 'application/vnd. wap. wmlc ',
'Wmlsc '=> 'application/vnd. wap. wmlscriptc ',
'Bcpio' => 'application/x-bcpio ',
'Vcd' => 'application/x-cdlink ',
'Pgn' => 'application/x-chess-pgn ',
'Cpio' => 'application/x-cpio ',
'Csh' => 'application/x-csh ',
'Dcr '=> 'application/x-ctor ',
'Dir' => 'application/x-ctor ',
'Dxr' => 'application/x-ctor ',
'Dvi '=> 'application/x-dvi ',
'Spl' => 'application/x-futuresplash ',
'Gtar '=> 'application/x-gtar ',
'Hdf' => 'application/x-hdf ',
'Js' => 'application/x-javascript ',
'Skp' => 'application/x-koan ',
'Skd' => 'application/x-koan ',
'Skt' => 'application/x-koan ',
'Skm' => 'application/x-koan ',
'Latex '=> 'application/x-latex ',
'Nc '=> 'application/x-netcdf ',
'Cdf' => 'application/x-netcdf ',
'Sh' => 'application/x-Sh ',
'Shar '=> 'application/x-shar ',
'Swf '=> 'application/x-shockwave-flash ',
'Sit '=> 'application/x-stuffit ',
'Sv4cpio '=> 'application/x-sv4cpio ',
'Sv4crc '=> 'application/x-sv4crc ',
'Tar '=> 'application/x-tar ',
'Tcl '=> 'application/x-tcl ',
'Tex '=> 'application/x-tex ',
'Textinfo' => 'application/x-textinfo ',
'Text' => 'application/x-textinfo ',
'T' => 'application/x-troff ',
'Tr' => 'application/x-troff ',
'Roff' => 'application/x-troff ',
'Man '=> 'application/x-troff-man ',
'Me' => 'application/x-troff-me ',
'Ms' => 'application/x-troff-Ms ',
'Ustar' => 'application/x-ustar ',
'Src' => 'application/x-wais-source ',
'Xhtml '=> 'application/xhtml + xml ',
'Xht '=> 'application/xhtml + xml ',
'Zip' => 'application/zip ',
'Au '=> 'audio/basic ',
'Snd' => 'audio/basic ',
'Mid '=> 'audio/midi ',
'Midi '=> 'audio/midi ',
'Kar '=> 'audio/midi ',
'Mpga' => 'audio/mpeg ',
'Mp2' => 'audio/mpeg ',
'Mp3' => 'audio/mpeg ',
'Aif' => 'audio/x-aiff ',
'Aiff '=> 'audio/x-aiff ',
'Aifc '=> 'audio/x-aiff ',
'M3u' => 'audio/x-mpegurl ',
'Ram '=> 'audio/x-pn-realaudio ',
'Rm '=> 'audio/x-pn-realaudio ',
'Rpm '=> 'audio/x-pn-realaudio-plugin ',
'A' => 'audio/x-realaudio ',
'Wav '=> 'audio/x-wav ',
'Pdb' => 'chemical/x-pdb ',
'Xyz' => 'chemical/x-xyz ',
'Bmp '=> 'image/bmp ',
'Gif' => 'image/gif ',
'Ief' => 'image/ief ',
'Jpeg '=> 'image/jpeg ',
'Jpg '=> 'image/jpeg ',
'Jpe' => 'image/jpeg ',
'Png '=> 'image/png ',
'Tiff '=> 'image/tiff ',
'Tif '=> 'image/tiff ',
'Djvu '=> 'image/vnd. djvu ',
'Djv' => 'image/vnd. djvu ',
'Wbmp '=> 'image/vnd. wap. wbmp ',
'Ras '=> 'image/x-cmu-raster ',
'Pnm '=> 'image/x-portable-anymap ',
'Pbm' => 'image/x-portable-bitmap ',
'Pgm '=> 'image/x-portable-graymap ',
'Ppm '=> 'image/x-portable-pixmap ',
'Rgb '=> 'image/x-rgb ',
'Xbm '=> 'image/x-xbitmap ',
'Xpm' => 'image/x-xpixmap ',
'Xwd '=> 'image/x-xwindowdump ',
'Gies' => 'model/iges ',
& Apos; iges & apos; = & apos; model/iges & apos ',
'Msh' => 'model/mesh ',
'Mesh '=> 'model/mesh ',
'Silo' => 'model/mesh ',
'Wrl' => 'model/jpa ',
'Jpa' => 'model/jpa ',
'Css '=> 'text/css ',
'Html' => 'text/html ',
'Htm '=> 'text/html ',
'Asc '=> 'text/plain ',
'Txt '=> 'text/plain ',
'Rtx' => 'text/richtext ',
'Rtf '=> 'text/rtf ',
'Sgml' => 'text/sgml ',
'Sgm' => 'text/sgml ',
'Tsv' => 'text/tab-separated-values ',
'Wml' => 'text/vnd. wap. wml ',
'Wmls' => 'text/vnd. wap. wmlscript ',
'Etx' => 'text/x-setext ',
'Xsl '=> 'text/xml ',
'Xml' => 'text/xml ',
'Mpeg '=> 'video/mpeg ',
'Mpg' => 'video/mpeg ',
'Mpe' => 'video/mpeg ',
'Qt '=> 'video/quicktime ',
'Mov' => 'video/quicktime ',
'Mxu' => 'video/vnd. mpegurl ',
'Av' => 'video/x-msvideo ',
'Movi' => 'video/x-sgi-movi ',
'Ice '=> 'x-conference/x-cooltalk ',

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.