Media Types and Subtypes
Media types are used to communicate the
format of the content in HTTP transactions. Clients use media types
in their Accept
headers to indicate what formats
they prefer to receive data in. Servers use media types in their
Content-Type
headers to tell the client what
format the accompanying entity is in—i.e., whether the enclosed
text is HTML that needs to be formatted, GIF or JPEG to be rendered,
or PDF that requires opening an external viewer or using a plug-in.
Internet media types used by HTTP
closely resemble MIME types. MIME (Multipurpose Internet Mail
Extension) was designed as a method for sending attachments in email
over the Internet. Like MIME, media types follow the format
type/subtype. Asterisks (*
)
represent a wildcard. For example, the following client header means
that documents of all formats are accepted:
Accept: */*
The following client header means that all text
format types are accepted, regardless of the subtype:
Accept: text/*
Servers and CGI programs are expected to examine the format types
reported by the Accept
header and return data of
an acceptable type when possible. Most servers determine the format
of a document from its filename suffix—for example, a file
ending with .htm or .html
is assumed to be HTML format, so the server sends the document with a
Content-Type
of text/html
. When calling a CGI program, servers cannot know the format of the data being returned, so the CGI program is responsible for reporting the content ...
Get Webmaster in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.