Java Reference
In-Depth Information
The last keyword in this example is Accept , which tells the server the types of data the
client can handle (though servers often ignore this). For example, the following line says
that the client can handle four MIME media types, corresponding to HTML documents,
plain text, and JPEG and GIF images:
Accept: text/html, text/plain, image/gif, image/jpeg
MIME types are classified at two levels: a type and a subtype. The type shows very generally
what kind of data is contained: is it a picture, text, or movie? The subtype identifies the
specific type of data: GIF image, JPEG image, TIFF image. For example, HTML's content
type is text/html ; the type is text , and the subtype is html . The content type for a JPEG
image is image/jpeg ; the type is image , and the subtype is jpeg . Eight top-level types
have been defined:
• text/* for human-readable words
• image/* for pictures
• model/* for 3D models such as VRML files
• audio/* for sound
• video/* for moving pictures, possibly including sound
• application/* for binary data
• message/* for protocol-specific envelopes such as email messages and HTTP re‐
sponses
• multipart/* for containers of multiple documents and resources
Each of these has many different subtypes.
The most current list of registered MIME types is available from http://www.iana.org/
assignments/media-types/ . In addition, nonstandard custom types and subtypes can be
freely defined as long as they begin with x- . For example, Flash files are commonly
assigned the type application/x-shockwave-flash .
Finally, the request is terminated with a blank line—that is, two carriage return/linefeed
pairs, \r\n\r\n .
Once the server sees that blank line, it begins sending its response to the client over the
same connection. The response begins with a status line, followed by a header describing
the response using the same “name: value” syntax as the request header, a blank line,
and the requested resource. A typical successful response looks something like this:
HTTP/1.1 200 OK
Date: Sun, 21 Apr 2013 15:12:46 GMT
Server: Apache
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Content-length: 115
Search WWH ::




Custom Search