解析Response对象

In ASP.NET this is represented as the Response object. When the Web server responds to a request, the communication is typically in the following text-based format:

1.HTTP/1.1 200 OK
2.Server: Microsoft-IIS/6.0
3.Content-Type: text/html
4.Content-Length: 38
5.<html><body>Hello, world.</body><html>

The first line contains the protocol and version information, plus a status-code and reason.

Status-Code Description

Group

1xx

Informational: Request received, continuing to process.

2xx

Success: The action was successfully received, understood, and accepted.

3xx

Redirect Command: Further action must be taken in order to complete the request.

4xx

Client Error: The request has a syntax error or the server does not know how to fulfill the request.

5xx

Server Error: The server failed to fulfill a request that appears to be valid.

In addition to the status-code groups, HTTP/1.1 defines unique status-codes and reasons. (A reason is nothing more than a very brief description of the status-code.)

Status-Code

Reason

100

Continue

200

OK

201

Created

300

Multiple Choices

301

Moved Permanently

302

Found

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

407

Proxy Authentication Required

408

Request Time-out

413

Request Entity Too Large

500

Internal Server Error

501

Not Implemented

The second line of the response indicates the type of Web server.
The third line (Content-Type) indicates the type of resource that is being sent to the Web browser. This indicator is in the form of a Multipurpose Internet Mail Extensions (MIME) type. In this case, the file is a static HTML text file. The MIME type is a two-part designator "type/subtype," in which the first part is the resource type and the second part is the resource subtype. 

MIME Type

Description

text

Textual information. No special software is required to get the full meaning of the text, aside from support for the indicated character set. One subtype is plain, which means that the text can be read without requiring additional software. Other subtypes are html and xml, which indicate the appropriate file type(s).

image

Image data. Requires a display device (such as a graphical display or a graphics printer) to view the information. Subtypes are defined for two widely used image formats, jpeg and gif.

audio

Audio data. Requires an audio output device (such as a speaker or headphones) to "hear" the contents. An initial subtype called basic is defined for this type.

video

Video data. Requires the capability to display moving images, typically including specialized hardware and software. An initial sub-type called mpeg is defined for this type.

application

Other kinds of data, typically either uninterpreted binary data or information to be processed by an application. The subtype, called octet-stream, is to be used in the case of uninterpreted binary data, in which the simplest recommended action is to offer to write the information into a file for the user. The PostScript subtype is also defined for the transport of PostScript material.

More Info 

MIME Types The registry contains a list of MIME types/subtypes at the following location:

HKEY_CLASSES_ROOT\MIME\Database\Content Type.

After the content-length line, the response message is returned. This message is based on the MIME type. The browser attempts to handle the message based on its MIME type.

posted on 2008-03-12 10:24  Yolion  阅读(571)  评论(0编辑  收藏  举报