HTTP Entities and Internet Media Types
(Page 2 of 3)
Media Types and Subtypes
The most important concept that HTTP adopted from MIME was the use of standardized Internet media types, which describe the contents of an HTTP entity. Each media type consists of a top-level media type that defines its general nature, and a more specific subtype that indicates its form or structure. Additional parameters may also be supplied in some cases to provide more information to help a recipient interpret the entity. The formal syntax of an HTTP media type is the same as that used in MIME:
<type>/<subtype> [; parameter1 ; parameter2 ; parameterN ]
To understand the difference between a top-level media type and a subtype we need only take a couple of examples. Text documents use the general type text; within this, subtypes exist such as plain for regular unformatted text and html for HTML documents. So, an HTML document of the type commonly transported using HTTP will be identified with a media type of text/html. Similarly, image is a top-level media type, and has subtypes such as jpeg, gif and tiff. Photographs usually use image/jpeg, while line drawings are often seen as image/gif.
In HTTP, media types are most often seen in a special Content-Type entity header, which is present in any HTTP message that carries an entity. This header uses the same format as the header of the same name in MIME:
Content-Type: <type>/<subtype> [; parameter1 ; parameter2 ; parameterN ]
The other place where media types are used in HTTP is in the Accept request header, which may appear in an HTTP request sent by a client. If present, the purpose of this header is to tell the server what sorts of media types the client can handle, so the server will not send a response that cannot be processed. For example, if a client can only process text documents, it might send a request specifying this in an Accept header. This is part of the overall content negotiation process supported by HTTP.
When a media type is specified in an Accept header, either the subtype, or both the type and subtype, can be replaced by the * wildcard to represent any acceptable. For example, in an Accept header, the specification text/html refers to an HTML document, while text/* means any text type. The string */* means any type of media; this is usually used in combination with a q value as explained in the topic on the HTTP content negotiation process.
Home - Table Of Contents - Contact Us
The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005
© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.