The Wayback Machine - https://web.archive.org/web/20080516225206/http://www.webreference.com/html/tutorial29/1.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / html / tutorials / 29 / 1

index1234567

HTTP for HTML Authors, Part II

Developer News
SaaS Tool Offers Custom Database Development
MicrosoftÂ’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear

Specifying the content media type

When a Web server responds to an HTTP request with a document, it must specify a few things about this document. The first and most important bit of information is the media type of the document; the user agent has to know what kind of document this is before it can process it. The most common media type transferred over the Web is, of course, HTML.

The media type is specified using the appropriately named Content-Type HTTP header in the response. The value of this header is a MIME media type (MIME stands for Multipurpose Internet Mail Extensions, a standard for transfer of documents through e-mail that has been used far and wide outside the world of e-mail for such purposes). MIME media types (or MIME types for short) consist of a type and a subtype separated by a slash. For instance, the MIME type for HTML is text/html. In order to specify that a document returned in an HTTP response is an HTML document, a server would include the following header in the response:

Content-Type: text/html

The primary type, in this case text is one of eight different primary types. These are used to classify document types, and also to give a hint about a document's nature if the user agent doesn't understand the specific MIME type. For instance, documents that belong to one of the text types are always composed of text that can be displayed as-is, even though most subtypes, like HTML, contain extra semantics. Likewise all subtypes of the image primary type are images.

The list of MIME types is maintained by IANA, the Internet Assigned Numbers Authority. You can find the full list on IANA's Web site, but most of the time you'll be using a few of the most common types:

text/html
HTML Document
text/css
CSS Style Sheet
image/gif
GIF image
image/jpeg
JPEG image
image/png
PNG image

When your Web server is just serving out files from directories, it will usually handle the Content-Type header on its own. Most Web servers are configured to understand the media type of any file on your hard disk and supply the appropriate header to the browser when they serve the file through HTTP. However, you will have to worry about media types if you start writing extensions to your server that serve dynamically generated documents. A common example of this is the despised Web counter, one of those odometer-like things that read “there have been 3 visitors to this site since May 3rd, 1782.” The image used to display the number of visitors is usually generated on-the-fly to correspond to the actual number of visitors recorded by a program that generates the image; this program has to tell the Web server that the data it's producing is, say, of the type image/gif because the Web server can't just look at the image in advance and decide what Content-Type to use.

index1234567

Next Page...

http://www.internet.com/



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
How to Create an Ajax Autocomplete Text Field: Part 6 · Software Engineering for Ajax · Perl Pragma Primer
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Using File Virtualization for Disaster Recovery · VoIP Security: SIP—Versatile but Vulnerable · Around the World in 80 Nodes

URL: http://www.webreference.com/html/tutorial29/1.html

Produced by Stephanos Piperoglou
Created: January 24, 2001
Revised: February 28, 2001

Morty Proxy This is a proxified and sanitized view of the page, visit original site.